home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / dev / c / libiconv_src.lha / autoconf / acspecific.m4 < prev    next >
Encoding:
M4 Source File  |  2000-11-07  |  84.8 KB  |  2,868 lines

  1. dnl Macros that test for specific features.
  2. dnl This file is part of Autoconf.
  3. dnl Copyright (C) 1992, 93, 94, 95, 96, 1998 Free Software Foundation, Inc.
  4. dnl
  5. dnl This program is free software; you can redistribute it and/or modify
  6. dnl it under the terms of the GNU General Public License as published by
  7. dnl the Free Software Foundation; either version 2, or (at your option)
  8. dnl any later version.
  9. dnl
  10. dnl This program is distributed in the hope that it will be useful,
  11. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. dnl GNU General Public License for more details.
  14. dnl
  15. dnl You should have received a copy of the GNU General Public License
  16. dnl along with this program; if not, write to the Free Software
  17. dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  18. dnl 02111-1307, USA.
  19. dnl
  20. dnl As a special exception, the Free Software Foundation gives unlimited
  21. dnl permission to copy, distribute and modify the configure scripts that
  22. dnl are the output of Autoconf.  You need not follow the terms of the GNU
  23. dnl General Public License when using or distributing such scripts, even
  24. dnl though portions of the text of Autoconf appear in them.  The GNU
  25. dnl General Public License (GPL) does govern all other use of the material
  26. dnl that constitutes the Autoconf program.
  27. dnl
  28. dnl Certain portions of the Autoconf source text are designed to be copied
  29. dnl (in certain cases, depending on the input) into the output of
  30. dnl Autoconf.  We call these the "data" portions.  The rest of the Autoconf
  31. dnl source text consists of comments plus executable code that decides which
  32. dnl of the data portions to output in any given case.  We call these
  33. dnl comments and executable code the "non-data" portions.  Autoconf never
  34. dnl copies any of the non-data portions into its output.
  35. dnl
  36. dnl This special exception to the GPL applies to versions of Autoconf
  37. dnl released by the Free Software Foundation.  When you make and
  38. dnl distribute a modified version of Autoconf, you may extend this special
  39. dnl exception to the GPL to apply to your modified version as well, *unless*
  40. dnl your modified version has the potential to copy into its output some
  41. dnl of the text that was the non-data portion of the version that you started
  42. dnl with.  (In other words, unless your change moves or copies text from
  43. dnl the non-data portions to the data portions.)  If your modification has
  44. dnl such potential, you must delete any notice of this special exception
  45. dnl to the GPL from your modified version.
  46. dnl
  47. dnl Written by David MacKenzie, with help from
  48. dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
  49. dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
  50. dnl
  51. dnl Changed by Bruno Haible, 18 January 1999
  52.  
  53.  
  54. dnl ### Checks for programs
  55.  
  56.  
  57. dnl Check whether to use -n, \c, or newline-tab to separate
  58. dnl checking messages from result messages.
  59. dnl Idea borrowed from dist 3.0.
  60. dnl Internal use only.
  61. AC_DEFUN(AC_PROG_ECHO_N,
  62. [if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  63.   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
  64.   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
  65.     ac_n= ac_c='
  66. ' ac_t='    ' ac_tt=
  67.   else
  68.     ac_n=-n ac_c= ac_t= ac_tt='
  69.          '
  70.   fi
  71. else
  72.   ac_n= ac_c='\c' ac_t= ac_tt='
  73.          '
  74. fi
  75. ])
  76.  
  77. AC_DEFUN(AC_PROG_CC,
  78. [AC_BEFORE([$0], [AC_PROG_CPP])dnl
  79. AC_CHECK_PROG(CC, gcc, gcc)
  80. if test -z "$CC"; then
  81.   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
  82.   if test -z "$CC"; then
  83.     case "`uname -s`" in
  84.     *win32* | *WIN32*)
  85.       AC_CHECK_PROG(CC, cl, cl) ;;
  86.     esac
  87.   fi
  88.   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
  89. fi
  90.  
  91. AC_PROG_CC_WORKS
  92. AC_PROG_CC_GNU
  93.  
  94. if test $ac_cv_prog_gcc = yes; then
  95.   GCC=yes
  96. else
  97.   GCC=
  98. fi
  99.  
  100. dnl Check whether -g works, even if CFLAGS is set, in case the package
  101. dnl plays around with CFLAGS (such as to build both debugging and
  102. dnl normal versions of a library), tasteless as that idea is.
  103. ac_test_CFLAGS="${CFLAGS+set}"
  104. ac_save_CFLAGS="$CFLAGS"
  105. CFLAGS=
  106. dnl AC_PROG_CC_G
  107. if test "$ac_test_CFLAGS" = set; then
  108.   CFLAGS="$ac_save_CFLAGS"
  109. dnl # This doesn't work on Linux (libc-4.5.26): Because of differences between
  110. dnl # the shared and the static libraries there are less symbols available
  111. dnl # without -g than with -g. It is therefore better to run the configuration
  112. dnl # without -g and to add -g afterwards than the contrary. So don't add
  113. dnl # -g to the CFLAGS now.
  114. dnl elif test $ac_cv_prog_cc_g = yes; then
  115. dnl   if test "$GCC" = yes; then
  116. dnl     CFLAGS="-g -O2"
  117. dnl   else
  118. dnl     CFLAGS="-g"
  119. dnl   fi
  120. else
  121.   if test "$GCC" = yes; then
  122. dnl     CFLAGS="-O"
  123.     # Add "-O" to both the CC and CPP commands, to eliminate possible confusion
  124.     # that results from __OPTIMIZE__ being defined for CC but not CPP.
  125. changequote(, )dnl
  126.     if echo "$CC " | grep ' -O[1-9 ]' > /dev/null 2>&1; then
  127. changequote([, ])dnl
  128.       : # already optimizing
  129.     else
  130.       CC="$CC -O"
  131.       ac_cv_prog_CC="$CC"
  132.     fi
  133.   else
  134.     CFLAGS=
  135.   fi
  136. fi
  137. ])
  138.  
  139. AC_DEFUN(AC_PROG_CXX,
  140. [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
  141. AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, gcc)
  142.  
  143. AC_PROG_CXX_WORKS
  144. AC_PROG_CXX_GNU
  145.  
  146. if test $ac_cv_prog_gxx = yes; then
  147.   GXX=yes
  148. else
  149.   GXX=
  150. fi
  151.  
  152. dnl Check whether -g works, even if CXXFLAGS is set, in case the package
  153. dnl plays around with CXXFLAGS (such as to build both debugging and
  154. dnl normal versions of a library), tasteless as that idea is.
  155. ac_test_CXXFLAGS="${CXXFLAGS+set}"
  156. ac_save_CXXFLAGS="$CXXFLAGS"
  157. CXXFLAGS=
  158. dnl AC_PROG_CXX_G
  159. if test "$ac_test_CXXFLAGS" = set; then
  160.   CXXFLAGS="$ac_save_CXXFLAGS"
  161. dnl # This doesn't work on Linux (libc-4.5.26): Because of differences between
  162. dnl # the shared and the static libraries there are less symbols available
  163. dnl # without -g than with -g. It is therefore better to run the configuration
  164. dnl # without -g and to add -g afterwards than the contrary. So don't add
  165. dnl # -g to the CFLAGS now.
  166. dnl elif test $ac_cv_prog_cxx_g = yes; then
  167. dnl   if test "$GXX" = yes; then
  168. dnl     CXXFLAGS="-g -O2"
  169. dnl   else
  170. dnl     CXXFLAGS="-g"
  171. dnl   fi
  172. else
  173.   if test "$GXX" = yes; then
  174. dnl     CXXFLAGS="-O"
  175.     # Add "-O" to both the CXX and CXXCPP commands, to eliminate possible confu-
  176.     # sion that results from __OPTIMIZE__ being defined for CXX but not CXXCPP.
  177. changequote(, )dnl
  178.     if echo "$CXX " | grep ' -O[1-9 ]' > /dev/null; then
  179. changequote([, ])dnl
  180.       : # already optimizing
  181.     else
  182.       CXX="$CXX -O"
  183.       ac_cv_prog_CXX="$CXX"
  184.     fi
  185.   else
  186.     CXXFLAGS=
  187.   fi
  188. fi
  189. ])
  190.  
  191. dnl Determine a Fortran 77 compiler to use.  If `F77' is not already set
  192. dnl in the environment, check for `g77', `f77' and `f2c', in that order.
  193. dnl Set the output variable `F77' to the name of the compiler found.
  194. dnl 
  195. dnl If using `g77' (the GNU Fortran 77 compiler), then `AC_PROG_F77'
  196. dnl will set the shell variable `G77' to `yes', and empty otherwise.  If
  197. dnl the output variable `FFLAGS' was not already set in the environment,
  198. dnl then set it to `-g -02' for `g77' (or `-O2' where `g77' does not
  199. dnl accept `-g').  Otherwise, set `FFLAGS' to `-g' for all other Fortran
  200. dnl 77 compilers.
  201. dnl 
  202. dnl AC_PROG_F77()
  203. AC_DEFUN(AC_PROG_F77,
  204. [AC_BEFORE([$0], [AC_PROG_CPP])dnl
  205. if test -z "$F77"; then
  206.   AC_CHECK_PROGS(F77, g77 f77 f2c)
  207.     test -z "$F77" && AC_MSG_ERROR([no acceptable Fortran 77 compiler found in \$PATH])
  208. fi
  209.  
  210. AC_PROG_F77_WORKS
  211. AC_PROG_F77_GNU
  212.  
  213. if test $ac_cv_prog_g77 = yes; then
  214.   G77=yes
  215. dnl Check whether -g works, even if FFLAGS is set, in case the package
  216. dnl plays around with FFLAGS (such as to build both debugging and
  217. dnl normal versions of a library), tasteless as that idea is.
  218.   ac_test_FFLAGS="${FFLAGS+set}"
  219.   ac_save_FFLAGS="$FFLAGS"
  220.   FFLAGS=
  221.   AC_PROG_F77_G
  222.   if test "$ac_test_FFLAGS" = set; then
  223.     FFLAGS="$ac_save_FFLAGS"
  224.   elif test $ac_cv_prog_f77_g = yes; then
  225.     FFLAGS="-g -O2"
  226.   else
  227.     FFLAGS="-O2"
  228.   fi
  229. else
  230.   G77=
  231.   test "${FFLAGS+set}" = set || FFLAGS="-g"
  232. fi
  233. ])
  234.  
  235. AC_DEFUN(AC_PROG_CC_WORKS,
  236. [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) works])
  237. AC_LANG_SAVE
  238. AC_LANG_C
  239. AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross)
  240. AC_LANG_RESTORE
  241. AC_MSG_RESULT($ac_cv_prog_cc_works)
  242. if test $ac_cv_prog_cc_works = no; then
  243.   AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.])
  244. fi
  245. AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler])
  246. AC_MSG_RESULT($ac_cv_prog_cc_cross)
  247. cross_compiling=$ac_cv_prog_cc_cross
  248. ])
  249.  
  250. AC_DEFUN(AC_PROG_CXX_WORKS,
  251. [AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
  252. AC_LANG_SAVE
  253. AC_LANG_CPLUSPLUS
  254. AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
  255. AC_LANG_RESTORE
  256. AC_MSG_RESULT($ac_cv_prog_cxx_works)
  257. if test $ac_cv_prog_cxx_works = no; then
  258.   AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
  259. fi
  260. AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
  261. AC_MSG_RESULT($ac_cv_prog_cxx_cross)
  262. cross_compiling=$ac_cv_prog_cxx_cross
  263. ])
  264.  
  265. dnl Test whether the Fortran 77 compiler can compile and link a trivial
  266. dnl Fortran program.  Also, test whether the Fortran 77 compiler is a
  267. dnl cross-compiler (which may realistically be the case if the Fortran
  268. dnl compiler is `g77').
  269. dnl 
  270. dnl AC_PROG_F77_WORKS()
  271. AC_DEFUN(AC_PROG_F77_WORKS,
  272. [AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works])
  273. AC_LANG_SAVE
  274. AC_LANG_FORTRAN77
  275. AC_TRY_COMPILER(dnl
  276. [      program conftest
  277.       end
  278. ], ac_cv_prog_f77_works, ac_cv_prog_f77_cross)
  279. AC_LANG_RESTORE
  280. AC_MSG_RESULT($ac_cv_prog_f77_works)
  281. if test $ac_cv_prog_f77_works = no; then
  282.   AC_MSG_ERROR([installation or configuration problem: Fortran 77 compiler cannot create executables.])
  283. fi
  284. AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) is a cross-compiler])
  285. AC_MSG_RESULT($ac_cv_prog_f77_cross)
  286. cross_compiling=$ac_cv_prog_f77_cross
  287. ])
  288.  
  289. AC_DEFUN(AC_PROG_CC_GNU,
  290. [AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc,
  291. [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
  292. cat > conftest.c <<EOF
  293. #ifdef __GNUC__
  294.   yes;
  295. #endif
  296. EOF
  297. if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
  298.   ac_cv_prog_gcc=yes
  299. else
  300.   ac_cv_prog_gcc=no
  301. fi])])
  302.  
  303. AC_DEFUN(AC_PROG_CXX_GNU,
  304. [AC_CACHE_CHECK(whether we are using GNU C++, ac_cv_prog_gxx,
  305. [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
  306. cat > conftest.C <<EOF
  307. #ifdef __GNUC__
  308.   yes;
  309. #endif
  310. EOF
  311. if AC_TRY_COMMAND(${CXX-g++} -E conftest.C) | egrep yes >/dev/null 2>&1; then
  312.   ac_cv_prog_gxx=yes
  313. else
  314.   ac_cv_prog_gxx=no
  315. fi])])
  316.  
  317. dnl Test whether for Fortran 77 compiler is `g77' (the GNU Fortran 77
  318. dnl Compiler).  This test depends on whether the Fortran 77 compiler can
  319. dnl do CPP pre-processing.
  320. dnl 
  321. dnl AC_PROG_F77_GNU()
  322. AC_DEFUN(AC_PROG_F77_GNU,
  323. [AC_CACHE_CHECK(whether we are using GNU Fortran 77, ac_cv_prog_g77,
  324. [cat > conftest.fpp <<EOF
  325. #ifdef __GNUC__
  326.   yes
  327. #endif
  328. EOF
  329. if AC_TRY_COMMAND($F77 -E conftest.fpp) | egrep yes >/dev/null 2>&1; then
  330.   ac_cv_prog_g77=yes
  331. else
  332.   ac_cv_prog_g77=no
  333. fi])])
  334.  
  335. AC_DEFUN(AC_PROG_CC_G,
  336. [AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g,
  337. [echo 'void f(){}' > conftest.c
  338. if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
  339.   ac_cv_prog_cc_g=yes
  340. else
  341.   ac_cv_prog_cc_g=no
  342. fi
  343. rm -f conftest*
  344. ])])
  345.  
  346. AC_DEFUN(AC_PROG_CXX_G,
  347. [AC_CACHE_CHECK(whether ${CXX-g++} accepts -g, ac_cv_prog_cxx_g,
  348. [echo 'void f(){}' > conftest.cc
  349. if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
  350.   ac_cv_prog_cxx_g=yes
  351. else
  352.   ac_cv_prog_cxx_g=no
  353. fi
  354. rm -f conftest*
  355. ])])
  356.  
  357. dnl Test whether the Fortran 77 compiler can accept the `-g' option to
  358. dnl enable debugging.
  359. dnl 
  360. dnl AC_PROG_F77_G()
  361. AC_DEFUN(AC_PROG_F77_G,
  362. [AC_CACHE_CHECK(whether $F77 accepts -g, ac_cv_prog_f77_g,
  363. [cat > conftest.f << EOF
  364.        program conftest
  365.        end
  366. EOF
  367. if test -z "`$F77 -g -c conftest.f 2>&1`"; then
  368.   ac_cv_prog_f77_g=yes
  369. else
  370.   ac_cv_prog_f77_g=no
  371. fi
  372. rm -f conftest*
  373. ])])
  374.  
  375. AC_DEFUN(AC_PROG_GCC_TRADITIONAL,
  376. [AC_REQUIRE([AC_PROG_CC])dnl
  377. AC_REQUIRE([AC_PROG_CPP])dnl
  378. if test $ac_cv_prog_gcc = yes; then
  379.   AC_CACHE_CHECK(whether -traditional is needed for ${CC-cc} on this system,
  380.       ac_cv_prog_gcc_traditional,
  381. [  ac_pattern="Autoconf.*'x'"
  382.   AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
  383. Autoconf TIOCGETP],
  384.   ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
  385.  
  386.   if test $ac_cv_prog_gcc_traditional = no; then
  387.     AC_EGREP_CPP($ac_pattern, [#include <termio.h>
  388. Autoconf TCGETA],
  389.     ac_cv_prog_gcc_traditional=yes)
  390.   fi
  391.   if test $ac_cv_prog_gcc_traditional = no; then
  392.     # On some USL SVR4 systems, gcc's fixinc.svr4 modifies <signal.h> and
  393.     # <sys/signal.h> in such a way that "#include <signal.h>" results in a
  394.     # syntax error because of `sigset_t' if gcc is called with __STDC__=1
  395.     # but __STRICT_ANSI__ undefined. Remedy: use -traditional.
  396.     ac_prog='
  397. #include <sys/types.h>
  398. #include <signal.h>
  399. #ifdef __cplusplus
  400. extern "C" void exit(int);
  401. #endif
  402. int main() { exit(0); }'
  403.     echo "$ac_prog" > conftest.c
  404.     if eval $ac_link; then
  405.       :
  406.     else
  407.       ac_prog='
  408. #undef __STDC__
  409. #include <sys/types.h>
  410. #include <signal.h>
  411. #ifdef __cplusplus
  412. extern "C" void exit(int);
  413. #endif
  414. int main() { exit(0); }'
  415.       echo "$ac_prog" > conftest.c
  416.       if eval $ac_link; then
  417.         ac_cv_prog_gcc_traditional=yes
  418.       fi
  419.     fi
  420.     rm -f conftest*
  421.   fi])
  422.   if test $ac_cv_prog_gcc_traditional = yes; then
  423.     CC="$CC -traditional"
  424.   fi
  425. fi
  426. ])
  427.  
  428. AC_DEFUN(AC_PROG_CC_C_O,
  429. [if test "x$CC" != xcc; then
  430.   AC_MSG_CHECKING(whether $CC and cc understand -c and -o together)
  431. else
  432.   AC_MSG_CHECKING(whether cc understands -c and -o together)
  433. fi
  434. set dummy $CC; ac_cc="`echo [$]2 |
  435. changequote(, )dnl
  436.                sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
  437. changequote([, ])dnl
  438. AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
  439. [echo 'foo(){}' > conftest.c
  440. # Make sure it works both with $CC and with simple cc.
  441. # We do the test twice because some compilers refuse to overwrite an
  442. # existing .o file with -o, though they will create one.
  443. ac_try='${CC-cc} -c conftest.c -o conftest.o 1>&AC_FD_CC'
  444. if AC_TRY_EVAL(ac_try) &&
  445.    test -f conftest.o && AC_TRY_EVAL(ac_try);
  446. then
  447.   eval ac_cv_prog_cc_${ac_cc}_c_o=yes
  448.   if test "x$CC" != xcc; then
  449.     # Test first that cc exists at all.
  450.     if AC_TRY_COMMAND(cc -c conftest.c 1>&AC_FD_CC); then
  451.       ac_try='cc -c conftest.c -o conftest.o 1>&AC_FD_CC'
  452.       if AC_TRY_EVAL(ac_try) &&
  453.          test -f conftest.o && AC_TRY_EVAL(ac_try);
  454.       then
  455.         # cc works too.
  456.         :
  457.       else
  458.         # cc exists but doesn't like -o.
  459.         eval ac_cv_prog_cc_${ac_cc}_c_o=no
  460.       fi
  461.     fi
  462.   fi
  463. else
  464.   eval ac_cv_prog_cc_${ac_cc}_c_o=no
  465. fi
  466. rm -f conftest*
  467. ])dnl
  468. if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
  469.   AC_MSG_RESULT(yes)
  470. else
  471.   AC_MSG_RESULT(no)
  472.   AC_DEFINE(NO_MINUS_C_MINUS_O)
  473. fi
  474. ])
  475.  
  476. dnl Test if the Fortran 77 compiler accepts the options `-c' and `-o'
  477. dnl simultaneously, and define `F77_NO_MINUS_C_MINUS_O' if it does not.
  478. dnl
  479. dnl The usefulness of this macro is questionable, as I can't really see
  480. dnl why anyone would use it.  The only reason I include it is for
  481. dnl completeness, since a similar test exists for the C compiler.
  482. dnl 
  483. dnl AC_PROG_F77_C_O
  484. AC_DEFUN(AC_PROG_F77_C_O,
  485. [AC_BEFORE([$0], [AC_PROG_F77])dnl
  486. AC_MSG_CHECKING(whether $F77 understand -c and -o together)
  487. set dummy $F77; ac_f77="`echo [$]2 |
  488. changequote(, )dnl
  489. sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
  490. changequote([, ])dnl
  491. AC_CACHE_VAL(ac_cv_prog_f77_${ac_f77}_c_o,
  492. [cat > conftest.f << EOF
  493.        program conftest
  494.        end
  495. EOF
  496. # We do the `AC_TRY_EVAL' test twice because some compilers refuse to
  497. # overwrite an existing `.o' file with `-o', although they will create
  498. # one.
  499. ac_try='$F77 $FFLAGS -c conftest.f -o conftest.o 1>&AC_FD_CC'
  500. if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
  501.   eval ac_cv_prog_f77_${ac_f77}_c_o=yes
  502. else
  503.   eval ac_cv_prog_f77_${ac_f77}_c_o=no
  504. fi
  505. rm -f conftest*
  506. ])dnl
  507. if eval "test \"`echo '$ac_cv_prog_f77_'${ac_f77}_c_o`\" = yes"; then
  508.   AC_MSG_RESULT(yes)
  509. else
  510.   AC_MSG_RESULT(no)
  511.   AC_DEFINE(F77_NO_MINUS_C_MINUS_O)
  512. fi
  513. ])
  514.  
  515. dnl Define SET_MAKE to set ${MAKE} if make doesn't.
  516. AC_DEFUN(AC_PROG_MAKE_SET,
  517. [AC_MSG_CHECKING([whether ${MAKE-make} sets \$(MAKE)])
  518. set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'`
  519. AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set,
  520. [cat > conftestmake <<\EOF
  521. all:
  522.     @echo 'ac_maketemp="${MAKE}"'
  523. EOF
  524. changequote(, )dnl
  525. # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
  526. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
  527. changequote([, ])dnl
  528. if test -n "$ac_maketemp"; then
  529.   eval ac_cv_prog_make_${ac_make}_set=yes
  530. else
  531.   eval ac_cv_prog_make_${ac_make}_set=no
  532. fi
  533. rm -f conftestmake])dnl
  534. if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
  535.   AC_MSG_RESULT(yes)
  536.   SET_MAKE=
  537. else
  538.   AC_MSG_RESULT(no)
  539.   SET_MAKE="MAKE=${MAKE-make}"
  540. fi
  541. AC_SUBST([SET_MAKE])dnl
  542. ])
  543.  
  544. AC_DEFUN(AC_PROG_RANLIB,
  545. [AC_CHECK_PROG(RANLIB, ranlib, ranlib, :)])
  546.  
  547. dnl Check for mawk first since it's generally faster.
  548. AC_DEFUN(AC_PROG_AWK,
  549. [AC_CHECK_PROGS(AWK, mawk gawk nawk awk, )])
  550.  
  551. AC_DEFUN(AC_PROG_YACC,
  552. [AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)])
  553.  
  554. AC_DEFUN(AC_PROG_CPP,
  555. [AC_MSG_CHECKING(how to run the C preprocessor)
  556. # On Suns, sometimes $CPP names a directory.
  557. if test -n "$CPP" && test -d "$CPP"; then
  558.   CPP=
  559. fi
  560. if test -z "$CPP"; then
  561. AC_CACHE_VAL(ac_cv_prog_CPP,
  562. [  # This must be in double quotes, not single quotes, because CPP may get
  563.   # substituted into the Makefile and "${CC-cc}" will confuse make.
  564.   CPP="${CC-cc} -E"
  565.   if test -n "$GCC"; then
  566. dnl This is already part of AC_PROG_CC.
  567. dnl # Use the same optimization flags than for CC, because some things may
  568. dnl # depend upon __OPTIMIZE__.
  569. dnl CPP="$CPP -O"
  570.     # Suppress warning messages.
  571. dnl # When using gcc -traditional on machines that have <sys/cdefs.h>,
  572. dnl # the "-Dconst=" from AC_C_CONST and the "#define const __const" from
  573. dnl # <sys/cdefs.h> generate a warning. Unless suppressed, this warning
  574. dnl # causes later tests using AC_TRY_CPP to fail.
  575.     CPP="$CPP -w"
  576.   fi
  577.   # On the NeXT, cc -E runs the code through the compiler's parser,
  578.   # not just through cpp. On NeXTstep 3.1 the same holds for /lib/cpp; use
  579.   # "cc -E -traditional-cpp" instead.
  580. dnl Use a header file that comes with gcc, so configuring glibc
  581. dnl with a fresh cross-compiler works.
  582.   AC_TRY_CPP([#include <assert.h>
  583. Syntax Error], ac_have_cpp=1)
  584.   if test -z "$ac_have_cpp"; then
  585.     CPP="${CC-cc} -E -traditional-cpp"
  586.     AC_TRY_CPP([#include <assert.h>
  587. Syntax Error], ac_have_cpp=1)
  588.     if test -n "$ac_have_cpp"; then
  589.       CC="${CC-cc} -traditional-cpp"
  590.     else
  591.       CPP="${CC-cc} -nologo -E"
  592.       AC_TRY_CPP([#include <assert.h>
  593. Syntax Error], ac_have_cpp=1)
  594.       if test -n "$ac_have_cpp"; then
  595.         CC="${CC-cc} -nologo"
  596.       else
  597.         CPP=/lib/cpp
  598.       fi
  599.     fi
  600.   fi
  601.   ac_cv_prog_CC="$CC"
  602.   ac_cv_prog_CPP="$CPP"])dnl
  603.   CPP="$ac_cv_prog_CPP"
  604. else
  605.   ac_cv_prog_CPP="$CPP"
  606. fi
  607. AC_MSG_RESULT($CPP)
  608. AC_SUBST(CPP)dnl
  609. ])
  610.  
  611. AC_DEFUN(AC_PROG_CXXCPP,
  612. [AC_MSG_CHECKING(how to run the C++ preprocessor)
  613. if test -z "$CXXCPP"; then
  614. AC_CACHE_VAL(ac_cv_prog_CXXCPP,
  615. [AC_LANG_SAVE[]dnl
  616. AC_LANG_CPLUSPLUS[]dnl
  617.   CXXCPP="${CXX-g++} -E"
  618.   AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
  619.   ac_cv_prog_CXXCPP="$CXXCPP"
  620. AC_LANG_RESTORE[]dnl
  621. fi])dnl
  622. CXXCPP="$ac_cv_prog_CXXCPP"
  623. AC_MSG_RESULT($CXXCPP)
  624. AC_SUBST(CXXCPP)dnl
  625. ])
  626.  
  627. dnl Require finding the C or C++ preprocessor, whichever is the
  628. dnl current language.
  629. AC_DEFUN(AC_REQUIRE_CPP,
  630. [ifelse(AC_LANG, C, [AC_REQUIRE([AC_PROG_CPP])], [AC_REQUIRE([AC_PROG_CXXCPP])])])
  631.  
  632. AC_DEFUN(AC_PROG_LEX,
  633. [AC_CHECK_PROG(LEX, flex, flex, lex)
  634. if test -z "$LEXLIB"
  635. then
  636.   case "$LEX" in
  637.   flex*) ac_lib=fl ;;
  638.   *) ac_lib=l ;;
  639.   esac
  640.   AC_CHECK_LIB($ac_lib, yywrap, LEXLIB="-l$ac_lib")
  641. fi
  642. AC_SUBST(LEXLIB)])
  643.  
  644. dnl Check if lex declares yytext as a char * by default, not a char[].
  645. undefine([AC_DECL_YYTEXT])
  646. AC_DEFUN(AC_DECL_YYTEXT,
  647. [AC_REQUIRE_CPP()dnl
  648. AC_REQUIRE([AC_PROG_LEX])dnl
  649. AC_CACHE_CHECK(lex output file root, ac_cv_prog_lex_root,
  650. [# The minimal lex program is just a single line: %%.  But some broken lexes
  651. # (Solaris, I think it was) want two %% lines, so accommodate them.
  652. echo '%%
  653. %%' | $LEX
  654. if test -f lex.yy.c; then
  655.   ac_cv_prog_lex_root=lex.yy
  656. elif test -f lexyy.c; then
  657.   ac_cv_prog_lex_root=lexyy
  658. else
  659.   AC_MSG_ERROR(cannot find output from $LEX; giving up)
  660. fi])
  661. LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
  662. AC_SUBST(LEX_OUTPUT_ROOT)dnl
  663.  
  664. AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,
  665. [# POSIX says lex can declare yytext either as a pointer or an array; the
  666. # default is implementation-dependent. Figure out which it is, since
  667. # not all implementations provide the %pointer and %array declarations.
  668. ac_cv_prog_lex_yytext_pointer=no
  669. echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
  670. ac_save_LIBS="$LIBS"
  671. LIBS="$LIBS $LEXLIB"
  672. AC_TRY_LINK(`cat $LEX_OUTPUT_ROOT.c`, , ac_cv_prog_lex_yytext_pointer=yes)
  673. LIBS="$ac_save_LIBS"
  674. rm -f "${LEX_OUTPUT_ROOT}.c"
  675. ])
  676. if test $ac_cv_prog_lex_yytext_pointer = yes; then
  677.   AC_DEFINE(YYTEXT_POINTER)
  678. fi
  679. ])
  680.  
  681. AC_DEFUN(AC_PROG_INSTALL,
  682. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  683. # Find a good install program.  We prefer a C program (faster),
  684. # so one script is as good as another.  But avoid the broken or
  685. # incompatible versions:
  686. # SysV /etc/install, /usr/sbin/install
  687. # SunOS /usr/etc/install
  688. # IRIX /sbin/install
  689. # AIX /bin/install
  690. # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
  691. # AFS /usr/afsws/bin/install, which mishandles nonexistent args
  692. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
  693. # ./install, which can be erroneously created by make from ./install.sh.
  694. AC_MSG_CHECKING(for a BSD compatible install)
  695. if test -z "$INSTALL"; then
  696. AC_CACHE_VAL(ac_cv_path_install,
  697. [  IFS="${IFS=     }"; ac_save_IFS="$IFS"; IFS=":"
  698.   for ac_dir in $PATH; do
  699.     # Account for people who put trailing slashes in PATH elements.
  700.     case "$ac_dir/" in
  701.     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
  702.     *)
  703.       # OSF1 and SCO ODT 3.0 have their own names for install.
  704.       # Don't use installbsd from OSF since it installs stuff as root
  705.       # by default.
  706.       for ac_prog in ginstall scoinst install; do
  707.         if test -f $ac_dir/$ac_prog; then
  708.       if test $ac_prog = install &&
  709.             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
  710.         # AIX install.  It has an incompatible calling convention.
  711.         :
  712.       else
  713.         if test $ac_prog = installbsd &&
  714.           grep src/bos $ac_dir/$ac_prog >/dev/null 2>&1; then
  715.           # AIX installbsd doesn't work without option "-g".
  716.           :
  717.         else
  718.           ac_cv_path_install="$ac_dir/$ac_prog -c"
  719.           break 2
  720.         fi
  721.       fi
  722.     fi
  723.       done
  724.       ;;
  725.     esac
  726.   done
  727.   IFS="$ac_save_IFS"
  728. ])dnl
  729.   if test "${ac_cv_path_install+set}" = set; then
  730.     INSTALL="$ac_cv_path_install"
  731.   else
  732.     # As a last resort, use the slow shell script.  We don't cache a
  733.     # path for INSTALL within a source directory, because that will
  734.     # break other packages using the cache if that directory is
  735.     # removed, or if the path is relative.
  736.     INSTALL="$ac_install_sh"
  737.   fi
  738. fi
  739. dnl We do special magic for INSTALL instead of AC_SUBST, to get
  740. dnl relative paths right.
  741. AC_MSG_RESULT($INSTALL)
  742.  
  743. # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
  744. # It thinks the first close brace ends the variable substitution.
  745. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
  746. AC_SUBST(INSTALL_PROGRAM)dnl
  747.  
  748. test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
  749. AC_SUBST(INSTALL_SCRIPT)dnl
  750.  
  751. test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
  752. AC_SUBST(INSTALL_DATA)dnl
  753. ])
  754.  
  755. AC_DEFUN(AC_PROG_LN_S,
  756. [AC_MSG_CHECKING(whether ln -s works)
  757. AC_CACHE_VAL(ac_cv_prog_LN_S,
  758. [rm -f conftestdata
  759. if ln -s X conftestdata 2>/dev/null
  760. then
  761.   rm -f conftestdata
  762.   ac_cv_prog_LN_S="ln -s"
  763. else
  764.   ac_cv_prog_LN_S=ln
  765. fi])dnl
  766. LN_S="$ac_cv_prog_LN_S"
  767. if test "$ac_cv_prog_LN_S" = "ln -s"; then
  768.   AC_MSG_RESULT(yes)
  769. else
  770.   AC_MSG_RESULT(no)
  771. fi
  772. AC_SUBST(LN_S)dnl
  773. ])
  774.  
  775. define(AC_RSH,
  776. [errprint(__file__:__line__: [$0] has been removed; replace it with equivalent code
  777. )m4exit(4)])
  778.  
  779.  
  780. dnl ### Checks for header files
  781.  
  782.  
  783. AC_DEFUN(AC_HEADER_STDC,
  784. [AC_REQUIRE_CPP()dnl
  785. AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
  786. [AC_TRY_CPP([#include <stdlib.h>
  787. #include <stdarg.h>
  788. #include <string.h>
  789. #include <float.h>], ac_cv_header_stdc=yes, ac_cv_header_stdc=no)
  790.  
  791. if test $ac_cv_header_stdc = yes; then
  792.   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  793. AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
  794. fi
  795.  
  796. if test $ac_cv_header_stdc = yes; then
  797.   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  798. AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
  799. fi
  800.  
  801. if test $ac_cv_header_stdc = yes; then
  802.   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  803. AC_TRY_RUN([#include <ctype.h>
  804. #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
  805. #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
  806. #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
  807. int main () { int i; for (i = 0; i < 256; i++)
  808. if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
  809. exit (0); }
  810. ], , ac_cv_header_stdc=no, :)
  811. fi])
  812. if test $ac_cv_header_stdc = yes; then
  813.   AC_DEFINE(STDC_HEADERS)
  814. fi
  815. ])
  816.  
  817. AC_DEFUN(AC_UNISTD_H,
  818. [AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(unistd.h)])dnl
  819. AC_CHECK_HEADER(unistd.h, AC_DEFINE(HAVE_UNISTD_H))])
  820.  
  821. AC_DEFUN(AC_USG,
  822. [AC_OBSOLETE([$0],
  823.   [; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])dnl
  824. AC_MSG_CHECKING([for BSD string and memory functions])
  825. AC_TRY_LINK([#include <strings.h>], [rindex(0, 0); bzero(0, 0);],
  826.   [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); AC_DEFINE(USG)])])
  827.  
  828.  
  829. dnl If memchr and the like aren't declared in <string.h>, include <memory.h>.
  830. dnl To avoid problems, don't check for gcc2 built-ins.
  831. AC_DEFUN(AC_MEMORY_H,
  832. [AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])dnl
  833. AC_MSG_CHECKING(whether string.h declares mem functions)
  834. AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
  835. AC_MSG_RESULT($ac_found)
  836. if test $ac_found = no; then
  837.   AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
  838. fi
  839. ])
  840.  
  841. AC_DEFUN(AC_HEADER_MAJOR,
  842. [AC_CACHE_CHECK(whether sys/types.h defines makedev,
  843.   ac_cv_header_sys_types_h_makedev,
  844. [AC_TRY_LINK([#include <sys/types.h>], [return makedev(0, 0);],
  845.   ac_cv_header_sys_types_h_makedev=yes, ac_cv_header_sys_types_h_makedev=no)
  846. ])
  847.  
  848. if test $ac_cv_header_sys_types_h_makedev = no; then
  849. AC_CHECK_HEADER(sys/mkdev.h, [AC_DEFINE(MAJOR_IN_MKDEV)])
  850.  
  851.   if test $ac_cv_header_sys_mkdev_h = no; then
  852. AC_CHECK_HEADER(sys/sysmacros.h, [AC_DEFINE(MAJOR_IN_SYSMACROS)])
  853.   fi
  854. fi
  855. ])
  856.  
  857. AC_DEFUN(AC_HEADER_DIRENT,
  858. [ac_header_dirent=no
  859. AC_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h,
  860.   [ac_header_dirent=$ac_hdr; break])
  861. # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
  862. if test $ac_header_dirent = dirent.h; then
  863. AC_CHECK_LIB(dir, opendir, LIBS="$LIBS -ldir")
  864. else
  865. AC_CHECK_LIB(x, opendir, LIBS="$LIBS -lx")
  866. fi
  867. ])
  868.  
  869. dnl Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
  870. dnl defines the type `DIR'.  dirent.h on NextStep 3.2 doesn't.
  871. dnl AC_CHECK_HEADER_DIRENT(HEADER-FILE, ACTION-IF-FOUND)
  872. AC_DEFUN(AC_CHECK_HEADER_DIRENT,
  873. [ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
  874. AC_MSG_CHECKING([for $1 that defines DIR])
  875. AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe,
  876. [AC_TRY_COMPILE([#include <sys/types.h>
  877. #include <$1>], [DIR *dirp = 0;],
  878.   eval "ac_cv_header_dirent_$ac_safe=yes",
  879.   eval "ac_cv_header_dirent_$ac_safe=no")])dnl
  880. if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
  881.   AC_MSG_RESULT(yes)
  882.   $2
  883. else
  884.   AC_MSG_RESULT(no)
  885. fi
  886. ])
  887.  
  888. dnl Like AC_CHECK_HEADERS, except succeed only for a HEADER-FILE that
  889. dnl defines `DIR'.
  890. dnl AC_CHECK_HEADERS_DIRENT(HEADER-FILE... [, ACTION])
  891. define(AC_CHECK_HEADERS_DIRENT,
  892. [for ac_hdr in $1
  893. do
  894. AC_CHECK_HEADER_DIRENT($ac_hdr,
  895. [changequote(, )dnl
  896.   ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
  897. changequote([, ])dnl
  898.   AC_DEFINE_UNQUOTED($ac_tr_hdr) $2])dnl
  899. done])
  900.  
  901. AC_DEFUN(AC_DIR_HEADER,
  902. [AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl
  903. ac_header_dirent=no
  904. for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
  905.   AC_CHECK_HEADER_DIRENT($ac_hdr, [ac_header_dirent=$ac_hdr; break])
  906. done
  907.  
  908. case "$ac_header_dirent" in
  909. dirent.h) AC_DEFINE(DIRENT) ;;
  910. sys/ndir.h) AC_DEFINE(SYSNDIR) ;;
  911. sys/dir.h) AC_DEFINE(SYSDIR) ;;
  912. ndir.h) AC_DEFINE(NDIR) ;;
  913. esac
  914.  
  915. AC_CACHE_CHECK(whether closedir returns void, ac_cv_func_closedir_void,
  916. [AC_TRY_RUN([#include <sys/types.h>
  917. #include <$ac_header_dirent>
  918. int closedir(); int main() { exit(closedir(opendir(".")) != 0); }],
  919.   ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes, ac_cv_func_closedir_void=yes)])
  920. if test $ac_cv_func_closedir_void = yes; then
  921.   AC_DEFINE(VOID_CLOSEDIR)
  922. fi
  923. ])
  924.  
  925. AC_DEFUN(AC_HEADER_STAT,
  926. [AC_CACHE_CHECK(whether stat file-mode macros are broken,
  927.   ac_cv_header_stat_broken,
  928. [AC_EGREP_CPP([You lose], [#include <sys/types.h>
  929. #include <sys/stat.h>
  930.  
  931. #if defined(S_ISBLK) && defined(S_IFDIR)
  932. # if S_ISBLK (S_IFDIR)
  933. You lose.
  934. # endif
  935. #endif
  936.  
  937. #if defined(S_ISBLK) && defined(S_IFCHR)
  938. # if S_ISBLK (S_IFCHR)
  939. You lose.
  940. # endif
  941. #endif
  942.  
  943. #if defined(S_ISLNK) && defined(S_IFREG)
  944. # if S_ISLNK (S_IFREG)
  945. You lose.
  946. # endif
  947. #endif
  948.  
  949. #if defined(S_ISSOCK) && defined(S_IFREG)
  950. # if S_ISSOCK (S_IFREG)
  951. You lose.
  952. # endif
  953. #endif
  954. ], ac_cv_header_stat_broken=yes, ac_cv_header_stat_broken=no)])
  955. if test $ac_cv_header_stat_broken = yes; then
  956.   AC_DEFINE(STAT_MACROS_BROKEN)
  957. fi
  958. ])
  959.  
  960. AC_DEFUN(AC_DECL_SYS_SIGLIST,
  961. [AC_CACHE_CHECK([for sys_siglist declaration in signal.h or unistd.h],
  962.   ac_cv_decl_sys_siglist,
  963. [AC_TRY_COMPILE([#include <sys/types.h>
  964. #include <signal.h>
  965. /* NetBSD declares sys_siglist in unistd.h.  */
  966. #ifdef HAVE_UNISTD_H
  967. #include <unistd.h>
  968. #endif], [char *msg = *(sys_siglist + 1);],
  969.   ac_cv_decl_sys_siglist=yes, ac_cv_decl_sys_siglist=no)])
  970. if test $ac_cv_decl_sys_siglist = yes; then
  971.   AC_DEFINE(SYS_SIGLIST_DECLARED)
  972. fi
  973. ])
  974.  
  975. AC_DEFUN(AC_HEADER_SYS_WAIT,
  976. [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
  977.   ac_cv_header_sys_wait_h,
  978. [AC_TRY_COMPILE([#include <sys/types.h>
  979. #include <sys/wait.h>
  980. #ifndef WEXITSTATUS
  981. #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  982. #endif
  983. #ifndef WIFEXITED
  984. #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
  985. #endif], [int s;
  986. wait (&s);
  987. s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;],
  988. ac_cv_header_sys_wait_h=yes, ac_cv_header_sys_wait_h=no)])
  989. if test $ac_cv_header_sys_wait_h = yes; then
  990.   AC_DEFINE(HAVE_SYS_WAIT_H)
  991. fi
  992. ])
  993.  
  994.  
  995. dnl ### Checks for typedefs
  996.  
  997.  
  998. AC_DEFUN(AC_TYPE_GETGROUPS,
  999. [AC_REQUIRE([AC_TYPE_UID_T])dnl
  1000. AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
  1001. [AC_TRY_RUN(
  1002. changequote(<<, >>)dnl
  1003. <<
  1004. /* Thanks to Mike Rendell for this test.  */
  1005. #include <sys/types.h>
  1006. #define NGID 256
  1007. #undef MAX
  1008. #define MAX(x, y) ((x) > (y) ? (x) : (y))
  1009. int main()
  1010. {
  1011.   gid_t gidset[NGID];
  1012.   int i, n;
  1013.   union { gid_t gval; long lval; }  val;
  1014.  
  1015.   val.lval = -1;
  1016.   for (i = 0; i < NGID; i++)
  1017.     gidset[i] = val.gval;
  1018.   n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
  1019.                  gidset);
  1020.   /* Exit non-zero if getgroups seems to require an array of ints.  This
  1021.      happens when gid_t is short but getgroups modifies an array of ints.  */
  1022.   exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
  1023. }
  1024. >>,
  1025. changequote([, ])dnl
  1026.   ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int,
  1027.   ac_cv_type_getgroups=cross)
  1028. if test $ac_cv_type_getgroups = cross; then
  1029.   dnl When we can't run the test program (we are cross compiling), presume
  1030.   dnl that <unistd.h> has either an accurate prototype for getgroups or none.
  1031.   dnl Old systems without prototypes probably use int.
  1032.   AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h,
  1033.           ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int)
  1034. fi])
  1035. AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups)
  1036. ])
  1037.  
  1038. AC_DEFUN(AC_TYPE_UID_T,
  1039. [AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
  1040. [AC_EGREP_HEADER(uid_t, sys/types.h,
  1041.   ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
  1042. if test $ac_cv_type_uid_t = no; then
  1043.   AC_DEFINE(uid_t, int)
  1044.   AC_DEFINE(gid_t, int)
  1045. fi
  1046. ])
  1047.  
  1048. AC_DEFUN(AC_TYPE_SIZE_T,
  1049. [AC_CHECK_TYPE(size_t, unsigned)])
  1050.  
  1051. AC_DEFUN(AC_TYPE_PID_T,
  1052. [AC_CHECK_TYPE(pid_t, int)])
  1053.  
  1054. AC_DEFUN(AC_TYPE_OFF_T,
  1055. [AC_CHECK_TYPE(off_t, long)])
  1056.  
  1057. AC_DEFUN(AC_TYPE_MODE_T,
  1058. [AC_CHECK_TYPE(mode_t, int)])
  1059.  
  1060. dnl Note that identifiers starting with SIG are reserved by ANSI C.
  1061. AC_DEFUN(AC_TYPE_SIGNAL,
  1062. [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
  1063. [AC_TRY_COMPILE([#include <sys/types.h>
  1064. #include <signal.h>
  1065. #ifdef signal
  1066. #undef signal
  1067. #endif
  1068. extern
  1069. #ifdef __cplusplus
  1070. "C" void (*signal (int, void (*)(int)))(int);
  1071. #else
  1072. void (*signal ()) ();
  1073. #endif
  1074. ],
  1075. [int i;], ac_cv_type_signal=void, ac_cv_type_signal=int)])
  1076. AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal)
  1077. ])
  1078.  
  1079.  
  1080. dnl ### Checks for functions
  1081.  
  1082.  
  1083. AC_DEFUN(AC_FUNC_CLOSEDIR_VOID,
  1084. [AC_REQUIRE([AC_HEADER_DIRENT])dnl
  1085. AC_CACHE_CHECK(whether closedir returns void, ac_cv_func_closedir_void,
  1086. [AC_TRY_RUN([#include <sys/types.h>
  1087. #include <$ac_header_dirent>
  1088. int closedir(); int main() { exit(closedir(opendir(".")) != 0); }],
  1089.   ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes, ac_cv_func_closedir_void=yes)])
  1090. if test $ac_cv_func_closedir_void = yes; then
  1091.   AC_DEFINE(CLOSEDIR_VOID)
  1092. fi
  1093. ])
  1094.  
  1095. AC_DEFUN(AC_FUNC_FNMATCH,
  1096. [AC_CACHE_CHECK(for working fnmatch, ac_cv_func_fnmatch_works,
  1097. # Some versions of Solaris or SCO have a broken fnmatch function.
  1098. # So we run a test program.  If we are cross-compiling, take no chance.
  1099. # Thanks to John Oleynick and Franc,ois Pinard for this test.
  1100. [AC_TRY_RUN([int main() { exit (fnmatch ("a*", "abc", 0) != 0); }],
  1101. ac_cv_func_fnmatch_works=yes, ac_cv_func_fnmatch_works=no,
  1102. ac_cv_func_fnmatch_works=no)])
  1103. if test $ac_cv_func_fnmatch_works = yes; then
  1104.   AC_DEFINE(HAVE_FNMATCH)
  1105. fi
  1106. ])
  1107.  
  1108. AC_DEFUN(AC_FUNC_MMAP,
  1109. [AC_CHECK_HEADERS(unistd.h)
  1110. AC_CHECK_FUNCS(getpagesize)
  1111. AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
  1112. [AC_TRY_RUN([
  1113. /* Thanks to Mike Haertel and Jim Avera for this test.
  1114.    Here is a matrix of mmap possibilities:
  1115.     mmap private not fixed
  1116.     mmap private fixed at somewhere currently unmapped
  1117.     mmap private fixed at somewhere already mapped
  1118.     mmap shared not fixed
  1119.     mmap shared fixed at somewhere currently unmapped
  1120.     mmap shared fixed at somewhere already mapped
  1121.    For private mappings, we should verify that changes cannot be read()
  1122.    back from the file, nor mmap's back from the file at a different
  1123.    address.  (There have been systems where private was not correctly
  1124.    implemented like the infamous i386 svr4.0, and systems where the
  1125.    VM page cache was not coherent with the filesystem buffer cache
  1126.    like early versions of FreeBSD and possibly contemporary NetBSD.)
  1127.    For shared mappings, we should conversely verify that changes get
  1128.    propogated back to all the places they're supposed to be.
  1129.  
  1130.    Grep wants private fixed already mapped.
  1131.    The main things grep needs to know about mmap are:
  1132.    * does it exist and is it safe to write into the mmap'd area
  1133.    * how to use it (BSD variants)  */
  1134. #include <sys/types.h>
  1135. #include <fcntl.h>
  1136. #include <sys/mman.h>
  1137.  
  1138. /* This mess was copied from the GNU getpagesize.h.  */
  1139. #ifndef HAVE_GETPAGESIZE
  1140. # ifdef HAVE_UNISTD_H
  1141. #  include <unistd.h>
  1142. # endif
  1143.  
  1144. /* Assume that all systems that can run configure have sys/param.h.  */
  1145. # ifndef HAVE_SYS_PARAM_H
  1146. #  define HAVE_SYS_PARAM_H 1
  1147. # endif
  1148.  
  1149. # ifdef _SC_PAGESIZE
  1150. #  define getpagesize() sysconf(_SC_PAGESIZE)
  1151. # else /* no _SC_PAGESIZE */
  1152. #  ifdef HAVE_SYS_PARAM_H
  1153. #   include <sys/param.h>
  1154. #   ifdef EXEC_PAGESIZE
  1155. #    define getpagesize() EXEC_PAGESIZE
  1156. #   else /* no EXEC_PAGESIZE */
  1157. #    ifdef NBPG
  1158. #     define getpagesize() NBPG * CLSIZE
  1159. #     ifndef CLSIZE
  1160. #      define CLSIZE 1
  1161. #     endif /* no CLSIZE */
  1162. #    else /* no NBPG */
  1163. #     ifdef NBPC
  1164. #      define getpagesize() NBPC
  1165. #     else /* no NBPC */
  1166. #      ifdef PAGESIZE
  1167. #       define getpagesize() PAGESIZE
  1168. #      endif /* PAGESIZE */
  1169. #     endif /* no NBPC */
  1170. #    endif /* no NBPG */
  1171. #   endif /* no EXEC_PAGESIZE */
  1172. #  else /* no HAVE_SYS_PARAM_H */
  1173. #   define getpagesize() 8192    /* punt totally */
  1174. #  endif /* no HAVE_SYS_PARAM_H */
  1175. # endif /* no _SC_PAGESIZE */
  1176.  
  1177. #endif /* no HAVE_GETPAGESIZE */
  1178.  
  1179. #ifdef __cplusplus
  1180. extern "C" { void *malloc(unsigned); }
  1181. #else
  1182. char *malloc();
  1183. #endif
  1184.  
  1185. int
  1186. main()
  1187. {
  1188.     char *data, *data2, *data3;
  1189.     int i, pagesize;
  1190.     int fd;
  1191.  
  1192.     pagesize = getpagesize();
  1193.  
  1194.     /*
  1195.      * First, make a file with some known garbage in it.
  1196.      */
  1197.     data = malloc(pagesize);
  1198.     if (!data)
  1199.         exit(1);
  1200.     for (i = 0; i < pagesize; ++i)
  1201.         *(data + i) = rand();
  1202.     umask(0);
  1203.     fd = creat("conftestmmap", 0600);
  1204.     if (fd < 0)
  1205.         exit(1);
  1206.     if (write(fd, data, pagesize) != pagesize)
  1207.         exit(1);
  1208.     close(fd);
  1209.  
  1210.     /*
  1211.      * Next, try to mmap the file at a fixed address which
  1212.      * already has something else allocated at it.  If we can,
  1213.      * also make sure that we see the same garbage.
  1214.      */
  1215.     fd = open("conftestmmap", O_RDWR);
  1216.     if (fd < 0)
  1217.         exit(1);
  1218.     data2 = malloc(2 * pagesize);
  1219.     if (!data2)
  1220.         exit(1);
  1221.     data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
  1222.     if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
  1223.         MAP_PRIVATE | MAP_FIXED, fd, 0L))
  1224.         exit(1);
  1225.     for (i = 0; i < pagesize; ++i)
  1226.         if (*(data + i) != *(data2 + i))
  1227.             exit(1);
  1228.  
  1229.     /*
  1230.      * Finally, make sure that changes to the mapped area
  1231.      * do not percolate back to the file as seen by read().
  1232.      * (This is a bug on some variants of i386 svr4.0.)
  1233.      */
  1234.     for (i = 0; i < pagesize; ++i)
  1235.         *(data2 + i) = *(data2 + i) + 1;
  1236.     data3 = malloc(pagesize);
  1237.     if (!data3)
  1238.         exit(1);
  1239.     if (read(fd, data3, pagesize) != pagesize)
  1240.         exit(1);
  1241.     for (i = 0; i < pagesize; ++i)
  1242.         if (*(data + i) != *(data3 + i))
  1243.             exit(1);
  1244.     close(fd);
  1245.     unlink("conftestmmap");
  1246.     exit(0);
  1247. }
  1248. ], ac_cv_func_mmap_fixed_mapped=yes, ac_cv_func_mmap_fixed_mapped=no,
  1249. ac_cv_func_mmap_fixed_mapped=no)])
  1250. if test $ac_cv_func_mmap_fixed_mapped = yes; then
  1251.   AC_DEFINE(HAVE_MMAP)
  1252. fi
  1253. ])
  1254.  
  1255. AC_DEFUN(AC_FUNC_GETPGRP,
  1256. [AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
  1257. [AC_TRY_RUN([
  1258. /*
  1259.  * If this system has a BSD-style getpgrp(),
  1260.  * which takes a pid argument, exit unsuccessfully.
  1261.  *
  1262.  * Snarfed from Chet Ramey's bash pgrp.c test program
  1263.  */
  1264. #include <stdio.h>
  1265. #include <sys/types.h>
  1266.  
  1267. int     pid;
  1268. int     pg1, pg2, pg3, pg4;
  1269. int     ng, np, s, child;
  1270.  
  1271. int main()
  1272. {
  1273.         pid = getpid();
  1274.         pg1 = getpgrp(0);
  1275.         pg2 = getpgrp();
  1276.         pg3 = getpgrp(pid);
  1277.         pg4 = getpgrp(1);
  1278.  
  1279.         /*
  1280.          * If all of these values are the same, it's pretty sure that
  1281.          * we're on a system that ignores getpgrp's first argument.
  1282.          */
  1283.         if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3)
  1284.                 exit(0);
  1285.  
  1286.         child = fork();
  1287.         if (child < 0)
  1288.                 exit(1);
  1289.         else if (child == 0) {
  1290.                 np = getpid();
  1291.                 /*
  1292.                  * If this is Sys V, this will not work; pgrp will be
  1293.                  * set to np because setpgrp just changes a pgrp to be
  1294.                  * the same as the pid.
  1295.                  */
  1296.                 setpgrp(np, pg1);
  1297.                 ng = getpgrp(0);        /* Same result for Sys V and BSD */
  1298.                 if (ng == pg1) {
  1299.                         exit(1);
  1300.                 } else {
  1301.                         exit(0);
  1302.                 }
  1303.         } else {
  1304.                 wait(&s);
  1305.                 exit(s>>8);
  1306.         }
  1307. }
  1308. ], ac_cv_func_getpgrp_void=yes, ac_cv_func_getpgrp_void=no,
  1309.    AC_MSG_ERROR(cannot check getpgrp if cross compiling))
  1310. ])
  1311. if test $ac_cv_func_getpgrp_void = yes; then
  1312.   AC_DEFINE(GETPGRP_VOID)
  1313. fi
  1314. ])
  1315.  
  1316. AC_DEFUN(AC_FUNC_SETPGRP,
  1317. [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
  1318. AC_TRY_RUN([
  1319. #ifdef HAVE_UNISTD_H
  1320. #include <unistd.h>
  1321. #endif
  1322.  
  1323. /*
  1324.  * If this system has a BSD-style setpgrp, which takes arguments, exit
  1325.  * successfully.
  1326.  */
  1327. int main()
  1328. {
  1329.     if (setpgrp(1,1) == -1)
  1330.     exit(0);
  1331.     else
  1332.     exit(1);
  1333. }
  1334. ], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes,
  1335.    AC_MSG_ERROR(cannot check setpgrp if cross compiling))
  1336. )
  1337. if test $ac_cv_func_setpgrp_void = yes; then
  1338.   AC_DEFINE(SETPGRP_VOID)
  1339. fi
  1340. ])
  1341.  
  1342. AC_DEFUN(AC_FUNC_VPRINTF,
  1343. [AC_CHECK_FUNC(vprintf, AC_DEFINE(HAVE_VPRINTF))
  1344. if test "$ac_cv_func_vprintf" != yes; then
  1345. AC_CHECK_FUNC(_doprnt, AC_DEFINE(HAVE_DOPRNT))
  1346. fi
  1347. ])
  1348.  
  1349. AC_DEFUN(AC_FUNC_VFORK,
  1350. [AC_REQUIRE([AC_TYPE_PID_T])dnl
  1351. AC_CHECK_HEADER(vfork.h, AC_DEFINE(HAVE_VFORK_H))
  1352. AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
  1353. [AC_TRY_RUN([/* Thanks to Paul Eggert for this test.  */
  1354. #include <stdio.h>
  1355. #include <sys/types.h>
  1356. #include <sys/stat.h>
  1357. #ifdef HAVE_UNISTD_H
  1358. #include <unistd.h>
  1359. #endif
  1360. #ifdef HAVE_VFORK_H
  1361. #include <vfork.h>
  1362. #endif
  1363. /* On some sparc systems, changes by the child to local and incoming
  1364.    argument registers are propagated back to the parent.
  1365.    The compiler is told about this with #include <vfork.h>,
  1366.    but some compilers (e.g. gcc -O) don't grok <vfork.h>.
  1367.    Test for this by using a static variable whose address
  1368.    is put into a register that is clobbered by the vfork.  */
  1369. static int
  1370. #ifdef __cplusplus
  1371. sparc_address_test (int arg)
  1372. #else
  1373. sparc_address_test (arg) int arg;
  1374. #endif
  1375. {
  1376.   static pid_t child;
  1377.   if (!child) {
  1378.     child = vfork ();
  1379.     if (child < 0) {
  1380.       perror ("vfork");
  1381.       _exit(2);
  1382.     }
  1383.     if (!child) {
  1384.       arg = getpid();
  1385.       write(-1, "", 0);
  1386.       _exit (arg);
  1387.     }
  1388.   }
  1389. }
  1390. int main() {
  1391.   pid_t parent = getpid ();
  1392.   pid_t child;
  1393.  
  1394.   ((int (*)()) sparc_address_test) ();
  1395.  
  1396.   child = vfork ();
  1397.  
  1398.   if (child == 0) {
  1399.     /* Here is another test for sparc vfork register problems.
  1400.        This test uses lots of local variables, at least
  1401.        as many local variables as main has allocated so far
  1402.        including compiler temporaries.  4 locals are enough for
  1403.        gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe.
  1404.        A buggy compiler should reuse the register of parent
  1405.        for one of the local variables, since it will think that
  1406.        parent can't possibly be used any more in this routine.
  1407.        Assigning to the local variable will thus munge parent
  1408.        in the parent process.  */
  1409.     pid_t
  1410.       p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
  1411.       p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
  1412.     /* Convince the compiler that p..p7 are live; otherwise, it might
  1413.        use the same hardware register for all 8 local variables.  */
  1414.     if (p != p1 || p != p2 || p != p3 || p != p4
  1415.     || p != p5 || p != p6 || p != p7)
  1416.       _exit(1);
  1417.  
  1418.     /* On some systems (e.g. IRIX 3.3),
  1419.        vfork doesn't separate parent from child file descriptors.
  1420.        If the child closes a descriptor before it execs or exits,
  1421.        this munges the parent's descriptor as well.
  1422.        Test for this by closing stdout in the child.  */
  1423.     _exit(close(fileno(stdout)) != 0);
  1424.   } else {
  1425.     int status;
  1426.     struct stat st;
  1427.  
  1428.     while (wait(&status) != child)
  1429.       ;
  1430.     exit(
  1431.      /* Was there some problem with vforking?  */
  1432.      child < 0
  1433.  
  1434.      /* Did the child fail?  (This shouldn't happen.)  */
  1435.      || status
  1436.  
  1437.      /* Did the vfork/compiler bug occur?  */
  1438.      || parent != getpid()
  1439.  
  1440.      /* Did the file descriptor bug occur?  */
  1441.      || fstat(fileno(stdout), &st) != 0
  1442.      );
  1443.   }
  1444. }],
  1445. ac_cv_func_vfork_works=yes, ac_cv_func_vfork_works=no, AC_CHECK_FUNC(vfork)
  1446. ac_cv_func_vfork_works=$ac_cv_func_vfork)])
  1447. if test $ac_cv_func_vfork_works = no; then
  1448.   AC_DEFINE(vfork, fork)
  1449. fi
  1450. ])
  1451.  
  1452. AC_DEFUN(AC_FUNC_WAIT3,
  1453. [AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
  1454. [AC_TRY_RUN([#include <sys/types.h>
  1455. #include <sys/time.h>
  1456. #include <sys/resource.h>
  1457. #include <stdio.h>
  1458. /* HP-UX has wait3 but does not fill in rusage at all.  */
  1459. int main() {
  1460.   struct rusage r;
  1461.   int i;
  1462.   /* Use a field that we can force nonzero --
  1463.      voluntary context switches.
  1464.      For systems like NeXT and OSF/1 that don't set it,
  1465.      also use the system CPU time.  And page faults (I/O) for Linux.  */
  1466.   r.ru_nvcsw = 0;
  1467.   r.ru_stime.tv_sec = 0;
  1468.   r.ru_stime.tv_usec = 0;
  1469.   r.ru_majflt = r.ru_minflt = 0;
  1470.   switch (fork()) {
  1471.   case 0: /* Child.  */
  1472.     sleep(1); /* Give up the CPU.  */
  1473.     _exit(0);
  1474.   case -1: _exit(0); /* What can we do?  */
  1475.   default: /* Parent.  */
  1476.     wait3(&i, 0, &r);
  1477.     sleep(2); /* Avoid "text file busy" from rm on fast HP-UX machines.  */
  1478.     exit(r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
  1479.      && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
  1480.   }
  1481. }], ac_cv_func_wait3_rusage=yes, ac_cv_func_wait3_rusage=no,
  1482. ac_cv_func_wait3_rusage=no)])
  1483. if test $ac_cv_func_wait3_rusage = yes; then
  1484.   AC_DEFINE(HAVE_WAIT3)
  1485. fi
  1486. ])
  1487.  
  1488. AC_DEFUN(AC_FUNC_ALLOCA,
  1489. [AC_REQUIRE_CPP()dnl Set CPP; we run AC_EGREP_CPP conditionally.
  1490. # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
  1491. # for constant arguments.  Useless!
  1492. AC_CACHE_CHECK([for working alloca.h], ac_cv_header_alloca_h,
  1493. [AC_TRY_LINK([#include <alloca.h>], [char *p = alloca(2 * sizeof(int));],
  1494.   ac_cv_header_alloca_h=yes, ac_cv_header_alloca_h=no)])
  1495. if test $ac_cv_header_alloca_h = yes; then
  1496.   AC_DEFINE(HAVE_ALLOCA_H)
  1497. fi
  1498.  
  1499. AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
  1500. [AC_TRY_LINK([
  1501. #ifdef __GNUC__
  1502. # define alloca __builtin_alloca
  1503. #else
  1504. # ifdef _MSC_VER
  1505. #  include <malloc.h>
  1506. #  define alloca _alloca
  1507. # else
  1508. #  if HAVE_ALLOCA_H
  1509. #   include <alloca.h>
  1510. #  else
  1511. #   ifdef _AIX
  1512.  #pragma alloca
  1513. #   else
  1514. #    ifndef alloca /* predefined by HP cc +Olibcalls */
  1515. char *alloca ();
  1516. #    endif
  1517. #   endif
  1518. #  endif
  1519. # endif
  1520. #endif
  1521. ], [char *p = (char *) alloca(1);],
  1522.   ac_cv_func_alloca_works=yes, ac_cv_func_alloca_works=no)])
  1523. if test $ac_cv_func_alloca_works = yes; then
  1524.   AC_DEFINE(HAVE_ALLOCA)
  1525. fi
  1526.  
  1527. if test $ac_cv_func_alloca_works = no; then
  1528.   # The SVR3 libPW and SVR4 libucb both contain incompatible functions
  1529.   # that cause trouble.  Some versions do not even contain alloca or
  1530.   # contain a buggy version.  If you still want to use their alloca,
  1531.   # use ar to extract alloca.o from them instead of compiling alloca.c.
  1532.   ALLOCA=alloca.${ac_objext}
  1533.   AC_DEFINE(C_ALLOCA)
  1534.  
  1535. AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
  1536. [AC_EGREP_CPP(webecray,
  1537. [#if defined(CRAY) && ! defined(CRAY2)
  1538. webecray
  1539. #else
  1540. wenotbecray
  1541. #endif
  1542. ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
  1543. if test $ac_cv_os_cray = yes; then
  1544. for ac_func in _getb67 GETB67 getb67; do
  1545.   AC_CHECK_FUNC($ac_func, [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func)
  1546.   break])
  1547. done
  1548. fi
  1549.  
  1550. AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
  1551. [AC_TRY_RUN([find_stack_direction ()
  1552. {
  1553.   static char *addr = 0;
  1554.   auto char dummy;
  1555.   if (addr == 0)
  1556.     {
  1557.       addr = &dummy;
  1558.       return find_stack_direction ();
  1559.     }
  1560.   else
  1561.     return (&dummy > addr) ? 1 : -1;
  1562. }
  1563. int main ()
  1564. {
  1565.   exit (find_stack_direction() < 0);
  1566. }], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1,
  1567.   ac_cv_c_stack_direction=0)])
  1568. AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
  1569. fi
  1570. AC_SUBST(ALLOCA)dnl
  1571. ])
  1572.  
  1573. AC_DEFUN(AC_FUNC_GETLOADAVG,
  1574. [ac_have_func=no # yes means we've found a way to get the load average.
  1575.  
  1576. # Some systems with -lutil have (and need) -lkvm as well, some do not.
  1577. # On Solaris, -lkvm requires nlist from -lelf, so check that first
  1578. # to get the right answer into the cache.
  1579. AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
  1580. AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
  1581. # Check for the 4.4BSD definition of getloadavg.
  1582. AC_CHECK_LIB(util, getloadavg,
  1583.   [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
  1584.  
  1585. if test $ac_have_func = no; then
  1586.   # There is a commonly available library for RS/6000 AIX.
  1587.   # Since it is not a standard part of AIX, it might be installed locally.
  1588.   ac_getloadavg_LIBS="$LIBS"; LIBS="-L/usr/local/lib $LIBS"
  1589.   AC_CHECK_LIB(getloadavg, getloadavg,
  1590.     LIBS="-lgetloadavg $LIBS", LIBS="$ac_getloadavg_LIBS")
  1591. fi
  1592.  
  1593. # Make sure it is really in the library, if we think we found it.
  1594. AC_REPLACE_FUNCS(getloadavg)
  1595.  
  1596. if test $ac_cv_func_getloadavg = yes; then
  1597.   AC_DEFINE(HAVE_GETLOADAVG)
  1598.   ac_have_func=yes
  1599. else
  1600.   # Figure out what our getloadavg.c needs.
  1601.   ac_have_func=no
  1602.   AC_CHECK_HEADER(sys/dg_sys_info.h,
  1603.   [ac_have_func=yes; AC_DEFINE(DGUX)
  1604.   AC_CHECK_LIB(dgc, dg_sys_info)])
  1605.  
  1606.   # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
  1607.   # uses stabs), but it is still SVR4.  We cannot check for <elf.h> because
  1608.   # Irix 4.0.5F has the header but not the library.
  1609.   if test $ac_have_func = no && test $ac_cv_lib_elf_elf_begin = yes; then
  1610.     ac_have_func=yes; AC_DEFINE(SVR4)
  1611.   fi
  1612.  
  1613.   if test $ac_have_func = no; then
  1614.     AC_CHECK_HEADER(inq_stats/cpustats.h,
  1615.     [ac_have_func=yes; AC_DEFINE(UMAX)
  1616.     AC_DEFINE(UMAX4_3)])
  1617.   fi
  1618.  
  1619.   if test $ac_have_func = no; then
  1620.     AC_CHECK_HEADER(sys/cpustats.h,
  1621.     [ac_have_func=yes; AC_DEFINE(UMAX)])
  1622.   fi
  1623.  
  1624.   if test $ac_have_func = no; then
  1625.     AC_CHECK_HEADERS(mach/mach.h)
  1626.   fi
  1627.  
  1628.   AC_CHECK_HEADER(nlist.h,
  1629.   [AC_DEFINE(NLIST_STRUCT)
  1630.   AC_CACHE_CHECK([for n_un in struct nlist], ac_cv_struct_nlist_n_un,
  1631.   [AC_TRY_COMPILE([#include <nlist.h>],
  1632.   [struct nlist n; n.n_un.n_name = 0;],
  1633.   ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])
  1634.   if test $ac_cv_struct_nlist_n_un = yes; then
  1635.     AC_DEFINE(NLIST_NAME_UNION)
  1636.   fi
  1637.   ])dnl
  1638. fi # Do not have getloadavg in system libraries.
  1639.  
  1640. # Some definitions of getloadavg require that the program be installed setgid.
  1641. dnl FIXME Don't hardwire the path of getloadavg.c in the top-level directory.
  1642. AC_CACHE_CHECK(whether getloadavg requires setgid,
  1643.   ac_cv_func_getloadavg_setgid,
  1644. [AC_EGREP_CPP([Yowza Am I SETGID yet],
  1645. [#include "$srcdir/getloadavg.c"
  1646. #ifdef LDAV_PRIVILEGED
  1647. Yowza Am I SETGID yet
  1648. #endif],
  1649.   ac_cv_func_getloadavg_setgid=yes, ac_cv_func_getloadavg_setgid=no)])
  1650. if test $ac_cv_func_getloadavg_setgid = yes; then
  1651.   NEED_SETGID=true; AC_DEFINE(GETLOADAVG_PRIVILEGED)
  1652. else
  1653.   NEED_SETGID=false
  1654. fi
  1655. AC_SUBST(NEED_SETGID)dnl
  1656.  
  1657. if test $ac_cv_func_getloadavg_setgid = yes; then
  1658.   AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
  1659. [changequote(, )dnl
  1660.   # On Solaris, /dev/kmem is a symlink.  Get info on the real file.
  1661.   ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
  1662.   # If we got an error (system does not support symlinks), try without -L.
  1663.   test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
  1664.   ac_cv_group_kmem=`echo $ac_ls_output \
  1665.     | sed -ne 's/[     ][     ]*/ /g;
  1666.            s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\)  *.*/\1/;
  1667.            / /s/.* //;p;'`
  1668. changequote([, ])dnl
  1669. ])
  1670.   KMEM_GROUP=$ac_cv_group_kmem
  1671. fi
  1672. AC_SUBST(KMEM_GROUP)dnl
  1673. ])
  1674.  
  1675. AC_DEFUN(AC_FUNC_UTIME_NULL,
  1676. [AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
  1677. [rm -f conftestdata; > conftestdata
  1678. # Sequent interprets utime(file, 0) to mean use start of epoch.  Wrong.
  1679. AC_TRY_RUN([#include <sys/types.h>
  1680. #include <sys/stat.h>
  1681. int main() {
  1682. struct stat s, t;
  1683. exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0
  1684. && stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
  1685. && t.st_mtime - s.st_mtime < 120));
  1686. }], ac_cv_func_utime_null=yes, ac_cv_func_utime_null=no,
  1687.   ac_cv_func_utime_null=no)
  1688. rm -f core])
  1689. if test $ac_cv_func_utime_null = yes; then
  1690.   AC_DEFINE(HAVE_UTIME_NULL)
  1691. fi
  1692. ])
  1693.  
  1694. AC_DEFUN(AC_FUNC_STRCOLL,
  1695. [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
  1696. [AC_TRY_RUN([#include <string.h>
  1697. int main ()
  1698. {
  1699.   exit (strcoll ("abc", "def") >= 0 ||
  1700.     strcoll ("ABC", "DEF") >= 0 ||
  1701.     strcoll ("123", "456") >= 0);
  1702. }], ac_cv_func_strcoll_works=yes, ac_cv_func_strcoll_works=no,
  1703. ac_cv_func_strcoll_works=no)])
  1704. if test $ac_cv_func_strcoll_works = yes; then
  1705.   AC_DEFINE(HAVE_STRCOLL)
  1706. fi
  1707. ])
  1708.  
  1709. AC_DEFUN(AC_FUNC_SETVBUF_REVERSED,
  1710. [AC_CACHE_CHECK(whether setvbuf arguments are reversed,
  1711.   ac_cv_func_setvbuf_reversed,
  1712. [AC_TRY_RUN([#include <stdio.h>
  1713. /* If setvbuf has the reversed format, exit 0. */
  1714. int main () {
  1715.   /* This call has the arguments reversed.
  1716.      A reversed system may check and see that the address of main
  1717.      is not _IOLBF, _IONBF, or _IOFBF, and return nonzero.  */
  1718.   if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
  1719.     exit(1);
  1720.   putc('\r', stdout);
  1721.   exit(0);            /* Non-reversed systems segv here.  */
  1722. }], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no)
  1723. rm -f core])
  1724. if test $ac_cv_func_setvbuf_reversed = yes; then
  1725.   AC_DEFINE(SETVBUF_REVERSED)
  1726. fi
  1727. ])
  1728.  
  1729. AC_DEFUN(AC_FUNC_GETMNTENT,
  1730. [# getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware.
  1731. AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS",
  1732.   [AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS",
  1733.     [AC_CHECK_LIB(gen, getmntent, LIBS="-lgen $LIBS")])])
  1734. AC_CHECK_FUNC(getmntent, [AC_DEFINE(HAVE_GETMNTENT)])])
  1735.  
  1736. AC_DEFUN(AC_FUNC_STRFTIME,
  1737. [AC_CHECK_FUNC(strftime, [AC_DEFINE(HAVE_STRFTIME)],
  1738. [# strftime is in -lintl on SCO UNIX.
  1739. AC_CHECK_LIB(intl, strftime, 
  1740. [AC_DEFINE(HAVE_STRFTIME)
  1741. LIBS="-lintl $LIBS"])])])
  1742.  
  1743. AC_DEFUN(AC_FUNC_MEMCMP,
  1744. [AC_CACHE_CHECK(for 8-bit clean memcmp, ac_cv_func_memcmp_clean,
  1745. [AC_TRY_RUN([
  1746. int main()
  1747. {
  1748.   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
  1749.   exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
  1750. }
  1751. ], ac_cv_func_memcmp_clean=yes, ac_cv_func_memcmp_clean=no,
  1752. ac_cv_func_memcmp_clean=no)])
  1753. test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
  1754. AC_SUBST(LIBOBJS)dnl
  1755. ])
  1756.  
  1757. AC_DEFUN(AC_FUNC_SELECT_ARGTYPES,
  1758. [AC_MSG_CHECKING([types of arguments for select()])
  1759.  AC_CACHE_VAL(ac_cv_func_select_arg234,dnl
  1760.  [AC_CACHE_VAL(ac_cv_func_select_arg1,dnl
  1761.   [AC_CACHE_VAL(ac_cv_func_select_arg5,dnl
  1762.    [for ac_cv_func_select_arg234 in 'fd_set *' 'int *' 'void *'; do
  1763.      for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
  1764.       for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
  1765.        AC_TRY_COMPILE(dnl
  1766. [#ifdef HAVE_SYS_TYPES_H
  1767. #include <sys/types.h>
  1768. #endif
  1769. #ifdef HAVE_SYS_TIME_H
  1770. #include <sys/time.h>
  1771. #endif
  1772. #ifdef HAVE_SYS_SELECT_H
  1773. #include <sys/select.h>
  1774. #endif
  1775. #ifdef HAVE_SYS_SOCKET_H
  1776. #include <sys/socket.h>
  1777. #endif
  1778. extern select ($ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5);],,dnl
  1779.         [ac_not_found=no ; break 3],ac_not_found=yes)
  1780.       done
  1781.      done
  1782.     done
  1783.    ])dnl AC_CACHE_VAL
  1784.   ])dnl AC_CACHE_VAL
  1785.  ])dnl AC_CACHE_VAL
  1786.  if test "$ac_not_found" = yes; then
  1787.   ac_cv_func_select_arg1=int 
  1788.   ac_cv_func_select_arg234='int *' 
  1789.   ac_cv_func_select_arg5='struct timeval *'
  1790.  fi
  1791.  AC_MSG_RESULT([$ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5])
  1792.  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1,$ac_cv_func_select_arg1)
  1793.  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234,($ac_cv_func_select_arg234))
  1794.  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5,($ac_cv_func_select_arg5))
  1795. ])
  1796.  
  1797.  
  1798. dnl ### Checks for structure members
  1799.  
  1800.  
  1801. AC_DEFUN(AC_HEADER_TIME,
  1802. [AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
  1803.   ac_cv_header_time,
  1804. [AC_TRY_COMPILE([#include <sys/types.h>
  1805. #include <sys/time.h>
  1806. #include <time.h>],
  1807. [struct tm *tp;], ac_cv_header_time=yes, ac_cv_header_time=no)])
  1808. if test $ac_cv_header_time = yes; then
  1809.   AC_DEFINE(TIME_WITH_SYS_TIME)
  1810. fi
  1811. ])
  1812.  
  1813. AC_DEFUN(AC_STRUCT_TM,
  1814. [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
  1815.   ac_cv_struct_tm,
  1816. [AC_TRY_COMPILE([#include <sys/types.h>
  1817. #include <time.h>],
  1818. [struct tm *tp; tp->tm_sec;],
  1819.   ac_cv_struct_tm=time.h, ac_cv_struct_tm=sys/time.h)])
  1820. if test $ac_cv_struct_tm = sys/time.h; then
  1821.   AC_DEFINE(TM_IN_SYS_TIME)
  1822. fi
  1823. ])
  1824.  
  1825. AC_DEFUN(AC_STRUCT_TIMEZONE,
  1826. [AC_REQUIRE([AC_STRUCT_TM])dnl
  1827. AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
  1828. [AC_TRY_COMPILE([#include <sys/types.h>
  1829. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
  1830.   ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
  1831. if test "$ac_cv_struct_tm_zone" = yes; then
  1832.   AC_DEFINE(HAVE_TM_ZONE)
  1833. else
  1834.   AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
  1835. [AC_TRY_LINK(
  1836. changequote(<<, >>)dnl
  1837. <<#include <time.h>
  1838. #ifndef tzname /* For SGI.  */
  1839. extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
  1840. #endif>>,
  1841. changequote([, ])dnl
  1842. [atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
  1843.   if test $ac_cv_var_tzname = yes; then
  1844.     AC_DEFINE(HAVE_TZNAME)
  1845.   fi
  1846. fi
  1847. ])
  1848.  
  1849. AC_DEFUN(AC_STRUCT_ST_BLOCKS,
  1850. [AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks,
  1851. [AC_TRY_COMPILE([#include <sys/types.h>
  1852. #include <sys/stat.h>], [struct stat s; s.st_blocks;],
  1853. ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])
  1854. if test $ac_cv_struct_st_blocks = yes; then
  1855.   AC_DEFINE(HAVE_ST_BLOCKS)
  1856. else
  1857.   LIBOBJS="$LIBOBJS fileblocks.${ac_objext}"
  1858. fi
  1859. AC_SUBST(LIBOBJS)dnl
  1860. ])
  1861.  
  1862. AC_DEFUN(AC_STRUCT_ST_BLKSIZE,
  1863. [AC_CACHE_CHECK([for st_blksize in struct stat], ac_cv_struct_st_blksize,
  1864. [AC_TRY_COMPILE([#include <sys/types.h>
  1865. #include <sys/stat.h>], [struct stat s; s.st_blksize;],
  1866. ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)])
  1867. if test $ac_cv_struct_st_blksize = yes; then
  1868.   AC_DEFINE(HAVE_ST_BLKSIZE)
  1869. fi
  1870. ])
  1871.  
  1872. AC_DEFUN(AC_STRUCT_ST_RDEV,
  1873. [AC_CACHE_CHECK([for st_rdev in struct stat], ac_cv_struct_st_rdev,
  1874. [AC_TRY_COMPILE([#include <sys/types.h>
  1875. #include <sys/stat.h>], [struct stat s; s.st_rdev;],
  1876. ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)])
  1877. if test $ac_cv_struct_st_rdev = yes; then
  1878.   AC_DEFINE(HAVE_ST_RDEV)
  1879. fi
  1880. ])
  1881.  
  1882.  
  1883. dnl ### Checks for compiler characteristics
  1884.  
  1885.  
  1886. AC_DEFUN(AC_C_CROSS,
  1887. [AC_OBSOLETE([$0], [; it has been merged into AC_PROG_CC])])
  1888.  
  1889. AC_DEFUN(AC_C_CHAR_UNSIGNED,
  1890. [AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
  1891. [if test "$GCC" = yes; then
  1892.   # GCC predefines this symbol on systems where it applies.
  1893. AC_EGREP_CPP(yes,
  1894. [#ifdef __CHAR_UNSIGNED__
  1895.   yes
  1896. #endif
  1897. ], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
  1898. else
  1899. AC_TRY_RUN(
  1900. [/* volatile prevents gcc2 from optimizing the test away on sparcs.  */
  1901. #if !defined(__STDC__) || __STDC__ != 1
  1902. #define volatile
  1903. #endif
  1904. int main() {
  1905.   volatile char c = 255; exit(c < 0);
  1906. }], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
  1907. fi])
  1908. if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
  1909.   AC_DEFINE(__CHAR_UNSIGNED__)
  1910. fi
  1911. ])
  1912.  
  1913. AC_DEFUN(AC_C_LONG_DOUBLE,
  1914. [AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
  1915. [if test "$GCC" = yes; then
  1916.   ac_cv_c_long_double=yes
  1917. else
  1918. AC_TRY_RUN([int main() {
  1919. /* The Stardent Vistra knows sizeof(long double), but does not support it.  */
  1920. long double foo = 0.0;
  1921. /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
  1922. exit(sizeof(long double) < sizeof(double)); }],
  1923. ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
  1924. fi])
  1925. if test $ac_cv_c_long_double = yes; then
  1926.   AC_DEFINE(HAVE_LONG_DOUBLE)
  1927. fi
  1928. ])
  1929.  
  1930. AC_DEFUN(AC_INT_16_BITS,
  1931. [AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(int)])dnl
  1932. AC_MSG_CHECKING(whether int is 16 bits)
  1933. AC_TRY_RUN([int main() { exit(sizeof(int) != 2); }],
  1934.  [AC_MSG_RESULT(yes)
  1935.  AC_DEFINE(INT_16_BITS)], AC_MSG_RESULT(no))
  1936. ])
  1937.  
  1938. AC_DEFUN(AC_LONG_64_BITS,
  1939. [AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(long)])dnl
  1940. AC_MSG_CHECKING(whether long int is 64 bits)
  1941. AC_TRY_RUN([int main() { exit(sizeof(long int) != 8); }],
  1942.  [AC_MSG_RESULT(yes)
  1943.  AC_DEFINE(LONG_64_BITS)], AC_MSG_RESULT(no))
  1944. ])
  1945.  
  1946. AC_DEFUN(AC_C_BIGENDIAN,
  1947. [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
  1948. [ac_cv_c_bigendian=unknown
  1949. # See if sys/param.h defines the BYTE_ORDER macro.
  1950. AC_TRY_COMPILE([#include <sys/types.h>
  1951. #include <sys/param.h>], [
  1952. #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
  1953.  bogus endian macros
  1954. #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
  1955. AC_TRY_COMPILE([#include <sys/types.h>
  1956. #include <sys/param.h>], [
  1957. #if BYTE_ORDER != BIG_ENDIAN
  1958.  not big endian
  1959. #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
  1960. if test $ac_cv_c_bigendian = unknown; then
  1961. AC_TRY_RUN([int main () {
  1962.   /* Are we little or big endian?  From Harbison&Steele.  */
  1963.   union
  1964.   {
  1965.     long l;
  1966.     char c[sizeof (long)];
  1967.   } u;
  1968.   u.l = 1;
  1969.   exit (u.c[sizeof (long) - 1] == 1);
  1970. }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)
  1971. fi])
  1972. if test $ac_cv_c_bigendian = yes; then
  1973.   AC_DEFINE(WORDS_BIGENDIAN)
  1974. fi
  1975. ])
  1976.  
  1977. dnl Do nothing if the compiler accepts the inline keyword.
  1978. dnl Otherwise define inline to __inline__ or __inline if one of those work,
  1979. dnl otherwise define inline to be empty.
  1980. AC_DEFUN(AC_C_INLINE,
  1981. [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
  1982. [ac_cv_c_inline=no
  1983. for ac_kw in inline __inline__ __inline; do
  1984.   AC_TRY_COMPILE(, [} $ac_kw foo() {], [ac_cv_c_inline=$ac_kw; break])
  1985. done
  1986. ])
  1987. case "$ac_cv_c_inline" in
  1988.   inline | yes) ;;
  1989.   no) AC_DEFINE(inline, ) ;;
  1990.   *)  AC_DEFINE_UNQUOTED(inline, $ac_cv_c_inline) ;;
  1991. esac
  1992. ])
  1993.  
  1994. AC_DEFUN(AC_C_CONST,
  1995. [dnl This message is consistent in form with the other checking messages,
  1996. dnl and with the result message.
  1997. AC_CACHE_CHECK([for working const], ac_cv_c_const,
  1998. [AC_TRY_COMPILE(,
  1999. changequote(<<, >>)dnl
  2000. <<
  2001. #ifndef __cplusplus
  2002. /* Ultrix mips cc rejects this.  */
  2003. typedef int charset[2]; const charset x;
  2004. #endif
  2005. /* SunOS 4.1.1 cc rejects this.  */
  2006. char const *const *ccp;
  2007. char **p;
  2008. /* NEC SVR4.0.2 mips cc rejects this.  */
  2009. struct point {int x, y;};
  2010. static struct point const zero = {0,0};
  2011. /* AIX XL C 1.02.0.0 rejects this.
  2012.    It does not let you subtract one const X* pointer from another in an arm
  2013.    of an if-expression whose if-part is not a constant expression */
  2014. const char *g = "string";
  2015. ccp = &g + (g ? g-g : 0);
  2016. /* HPUX 7.0 cc rejects these. */
  2017. ++ccp;
  2018. p = (char**) ccp;
  2019. ccp = (char const *const *) p;
  2020. { /* SCO 3.2v4 cc rejects this.  */
  2021.   char *t;
  2022.   char const *s = 0 ? (char *) 0 : (char const *) 0;
  2023.  
  2024.   *t++ = 0;
  2025. }
  2026. { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
  2027.   int x[] = {25, 17};
  2028.   const int *foo = &x[0];
  2029.   ++foo;
  2030. }
  2031. { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
  2032.   typedef const int *iptr;
  2033.   iptr p = 0;
  2034.   ++p;
  2035. }
  2036. { /* AIX XL C 1.02.0.0 rejects this saying
  2037.      "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
  2038.   struct s { int j; const int *ap[3]; };
  2039.   struct s *b; b->j = 5;
  2040. }
  2041. { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
  2042.   const int foo = 10;
  2043. }
  2044. >>,
  2045. changequote([, ])dnl
  2046. ac_cv_c_const=yes, ac_cv_c_const=no)])
  2047. if test $ac_cv_c_const = no; then
  2048.   AC_DEFINE(const, )
  2049. fi
  2050. ])
  2051.  
  2052. AC_DEFUN(AC_C_STRINGIZE, [
  2053. AC_REQUIRE([AC_PROG_CPP])
  2054. AC_MSG_CHECKING([for preprocessor stringizing operator])
  2055. AC_CACHE_VAL(ac_cv_c_stringize,
  2056. AC_EGREP_CPP([#teststring],[
  2057. #define x(y) #y
  2058.  
  2059. char *s = x(teststring);
  2060. ], ac_cv_c_stringize=no, ac_cv_c_stringize=yes))
  2061. if test "${ac_cv_c_stringize}" = yes
  2062. then
  2063.         AC_DEFINE(HAVE_STRINGIZE)
  2064. fi
  2065. AC_MSG_RESULT([${ac_cv_c_stringize}])
  2066. ])dnl
  2067.  
  2068. define(AC_ARG_ARRAY,
  2069. [errprint(__file__:__line__: [$0] has been removed; don't do unportable things with arguments
  2070. )m4exit(4)])
  2071.  
  2072. dnl Check the object extension used by the compiler: typically .o or
  2073. dnl .obj.  If this is called, some other behaviour will change,
  2074. dnl determined by ac_objext.
  2075. AC_DEFUN(AC_OBJEXT,
  2076. [AC_MSG_CHECKING([for object suffix])
  2077. AC_CACHE_VAL(ac_cv_objext,
  2078. [rm -f conftest*
  2079. echo 'int i = 1;' > conftest.$ac_ext
  2080. if AC_TRY_EVAL(ac_compile); then
  2081.   for ac_file in conftest.*; do
  2082.     case $ac_file in
  2083.     *.c) ;;
  2084.     *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;;
  2085.     esac
  2086.   done
  2087. else
  2088.   AC_MSG_ERROR([installation or configuration problem; compiler does not work])
  2089. fi
  2090. rm -f conftest*])
  2091. AC_MSG_RESULT($ac_cv_objext)
  2092. OBJEXT=$ac_cv_objext
  2093. ac_objext=$ac_cv_objext
  2094. AC_SUBST(OBJEXT)])
  2095.  
  2096. dnl Determine the linker flags (e.g. `-L' and `-l') for the Fortran 77
  2097. dnl intrinsic and run-time libraries that are required to successfully
  2098. dnl link a Fortran 77 program or shared library.  The output variable
  2099. dnl FLIBS is set to these flags.
  2100. dnl 
  2101. dnl This macro is intended to be used in those situations when it is
  2102. dnl necessary to mix, e.g. C++ and Fortran 77, source code into a single
  2103. dnl program or shared library.
  2104. dnl 
  2105. dnl For example, if object files from a C++ and Fortran 77 compiler must
  2106. dnl be linked together, then the C++ compiler/linker must be used for
  2107. dnl linking (since special C++-ish things need to happen at link time
  2108. dnl like calling global constructors, instantiating templates, enabling
  2109. dnl exception support, etc.).
  2110. dnl 
  2111. dnl However, the Fortran 77 intrinsic and run-time libraries must be
  2112. dnl linked in as well, but the C++ compiler/linker doesn't know how to
  2113. dnl add these Fortran 77 libraries.  Hence, the macro
  2114. dnl `AC_F77_LIBRARY_LDFLAGS' was created to determine these Fortran 77
  2115. dnl libraries.
  2116. dnl
  2117. dnl This macro was packaged in its current form by Matthew D. Langston
  2118. dnl <langston@SLAC.Stanford.EDU>.  However, nearly all of this macro
  2119. dnl came from the `OCTAVE_FLIBS' macro in `octave-2.0.13/aclocal.m4',
  2120. dnl and full credit should go to John W. Eaton for writing this
  2121. dnl extremely useful macro.  Thank you John.
  2122. dnl
  2123. dnl AC_F77_LIBRARY_LDFLAGS()
  2124. AC_DEFUN(AC_F77_LIBRARY_LDFLAGS,
  2125. [AC_MSG_CHECKING([for Fortran 77 libraries])
  2126. AC_REQUIRE([AC_PROG_F77])
  2127. AC_REQUIRE([AC_CANONICAL_HOST])
  2128. AC_CACHE_VAL(ac_cv_flibs,
  2129. [changequote(, )dnl
  2130. dnl Write a minimal program and compile it with -v.  I don't know what
  2131. dnl to do if your compiler doesn't have -v...
  2132. echo "      END" > conftest.f
  2133. foutput=`${F77} -v -o conftest conftest.f 2>&1`
  2134. dnl
  2135. dnl The easiest thing to do for xlf output is to replace all the commas
  2136. dnl with spaces.  Try to only do that if the output is really from xlf,
  2137. dnl since doing that causes problems on other systems.
  2138. dnl
  2139. xlf_p=`echo $foutput | grep xlfentry`
  2140. if test -n "$xlf_p"; then
  2141.   foutput=`echo $foutput | sed 's/,/ /g'`
  2142. fi
  2143. dnl
  2144. ld_run_path=`echo $foutput | \
  2145.   sed -n -e 's/^.*LD_RUN_PATH *= *\([^ ]*\).*/\1/p'`
  2146. dnl
  2147. dnl We are only supposed to find this on Solaris systems...
  2148. dnl Uh, the run path should be absolute, shouldn't it?
  2149. dnl
  2150. case "$ld_run_path" in
  2151.   /*)
  2152.     if test "$ac_cv_prog_gcc" = yes; then
  2153.       ld_run_path="-Xlinker -R -Xlinker $ld_run_path"
  2154.     else
  2155.       ld_run_path="-R $ld_run_path"
  2156.     fi
  2157.   ;;
  2158.   *)
  2159.     ld_run_path=
  2160.   ;;
  2161. esac
  2162. dnl
  2163. flibs=
  2164. lflags=
  2165. dnl
  2166. dnl If want_arg is set, we know we want the arg to be added to the list,
  2167. dnl so we don't have to examine it.
  2168. dnl
  2169. want_arg=
  2170. dnl
  2171. for arg in $foutput; do
  2172.   old_want_arg=$want_arg
  2173.   want_arg=
  2174. dnl
  2175. dnl None of the options that take arguments expect the argument to
  2176. dnl start with a -, so pretend we didn't see anything special.
  2177. dnl
  2178.   if test -n "$old_want_arg"; then
  2179.     case "$arg" in
  2180.       -*)
  2181.         old_want_arg=
  2182.       ;;
  2183.     esac
  2184.   fi
  2185.   case "$old_want_arg" in
  2186.     '')
  2187.       case $arg in
  2188.         /*.a)
  2189.           exists=false
  2190.           for f in $lflags; do
  2191.             if test x$arg = x$f; then
  2192.               exists=true
  2193.             fi
  2194.           done
  2195.           if $exists; then
  2196.             arg=
  2197.           else
  2198.             lflags="$lflags $arg"
  2199.           fi
  2200.         ;;
  2201.         -bI:*)
  2202.           exists=false
  2203.           for f in $lflags; do
  2204.             if test x$arg = x$f; then
  2205.               exists=true
  2206.             fi
  2207.           done
  2208.           if $exists; then
  2209.             arg=
  2210.           else
  2211.             if test "$ac_cv_prog_gcc" = yes; then
  2212.               lflags="$lflags -Xlinker $arg"
  2213.             else
  2214.               lflags="$lflags $arg"
  2215.             fi
  2216.           fi
  2217.         ;;
  2218.         -lang* | -lcrt0.o | -lc | -lgcc)
  2219.           arg=
  2220.         ;;
  2221.         -[lLR])
  2222.           want_arg=$arg
  2223.           arg=
  2224.         ;;
  2225.         -[lLR]*)
  2226.           exists=false
  2227.           for f in $lflags; do
  2228.             if test x$arg = x$f; then
  2229.               exists=true
  2230.             fi
  2231.           done
  2232.           if $exists; then
  2233.             arg=
  2234.           else
  2235.             case "$arg" in
  2236.               -lkernel32)
  2237.                 case "$canonical_host_type" in
  2238.                   *-*-cygwin*)
  2239.                     arg=
  2240.                   ;;
  2241.                   *)
  2242.                     lflags="$lflags $arg"
  2243.                   ;;
  2244.                 esac
  2245.               ;;
  2246.               -lm)
  2247.               ;;
  2248.               *)
  2249.                 lflags="$lflags $arg"
  2250.               ;;
  2251.             esac
  2252.           fi
  2253.         ;;
  2254.         -u)
  2255.           want_arg=$arg
  2256.           arg=
  2257.         ;;
  2258.         -Y)
  2259.           want_arg=$arg
  2260.           arg=
  2261.         ;;
  2262.         *)
  2263.           arg=
  2264.         ;;
  2265.       esac
  2266.     ;;
  2267.     -[lLR])
  2268.       arg="$old_want_arg $arg"
  2269.     ;;
  2270.     -u)
  2271.       arg="-u $arg"
  2272.     ;;
  2273.     -Y)
  2274. dnl
  2275. dnl Should probably try to ensure unique directory options here too.
  2276. dnl This probably only applies to Solaris systems, and then will only
  2277. dnl work with gcc...
  2278. dnl
  2279.       arg=`echo $arg | sed -e 's%^P,%%'`
  2280.       SAVE_IFS=$IFS
  2281.       IFS=:
  2282.       list=
  2283.       for elt in $arg; do
  2284.         list="$list -L$elt"
  2285.       done
  2286.       IFS=$SAVE_IFS
  2287.       arg="$list"
  2288.     ;;
  2289.   esac
  2290. dnl
  2291.   if test -n "$arg"; then
  2292.     flibs="$flibs $arg"
  2293.   fi
  2294. done
  2295. if test -n "$ld_run_path"; then
  2296.   flibs_result="$ld_run_path $flibs"
  2297. else
  2298.   flibs_result="$flibs"
  2299. fi
  2300. changequote([, ])dnl
  2301. ac_cv_flibs="$flibs_result"])
  2302. FLIBS="$ac_cv_flibs"
  2303. AC_SUBST(FLIBS)dnl
  2304. AC_MSG_RESULT($FLIBS)
  2305. ])
  2306.  
  2307.  
  2308. dnl ### Checks for operating system services
  2309.  
  2310.  
  2311. AC_DEFUN(AC_SYS_INTERPRETER,
  2312. [# Pull the hash mark out of the macro call to avoid m4 problems.
  2313. ac_msg="whether #! works in shell scripts"
  2314. AC_CACHE_CHECK($ac_msg, ac_cv_sys_interpreter,
  2315. [echo '#! /bin/cat
  2316. exit 69
  2317. ' > conftest
  2318. chmod u+x conftest
  2319. (SHELL=/bin/sh; export SHELL; ./conftest >/dev/null)
  2320. if test $? -ne 69; then
  2321.    ac_cv_sys_interpreter=yes
  2322. else
  2323.    ac_cv_sys_interpreter=no
  2324. fi
  2325. rm -f conftest])
  2326. interpval="$ac_cv_sys_interpreter"
  2327. ])
  2328.  
  2329. define(AC_HAVE_POUNDBANG,
  2330. [errprint(__file__:__line__: [$0 has been replaced by AC_SYS_INTERPRETER, taking no arguments
  2331. ])m4exit(4)])
  2332.  
  2333. AC_DEFUN(AC_SYS_LONG_FILE_NAMES,
  2334. [AC_CACHE_CHECK(for long file names, ac_cv_sys_long_file_names,
  2335. [ac_cv_sys_long_file_names=yes
  2336. # Test for long file names in all the places we know might matter:
  2337. #      .        the current directory, where building will happen
  2338. #      $prefix/lib    where we will be installing things
  2339. #      $exec_prefix/lib    likewise
  2340. # eval it to expand exec_prefix.
  2341. #      $TMPDIR        if set, where it might want to write temporary files
  2342. # if $TMPDIR is not set:
  2343. #      /tmp        where it might want to write temporary files
  2344. #      /var/tmp        likewise
  2345. #      /usr/tmp        likewise
  2346. if test -n "$TMPDIR" && test -d "$TMPDIR" && test -w "$TMPDIR"; then
  2347.   ac_tmpdirs="$TMPDIR"
  2348. else
  2349.   ac_tmpdirs='/tmp /var/tmp /usr/tmp'
  2350. fi
  2351. for ac_dir in  . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do
  2352.   test -d $ac_dir || continue
  2353.   test -w $ac_dir || continue # It is less confusing to not echo anything here.
  2354.   (echo 1 > $ac_dir/conftest9012345) 2>/dev/null
  2355.   (echo 2 > $ac_dir/conftest9012346) 2>/dev/null
  2356.   val=`cat $ac_dir/conftest9012345 2>/dev/null`
  2357.   if test ! -f $ac_dir/conftest9012345 || test "$val" != 1; then
  2358.     ac_cv_sys_long_file_names=no
  2359.     rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
  2360.     break
  2361.   fi
  2362.   rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
  2363. done])
  2364. if test $ac_cv_sys_long_file_names = yes; then
  2365.   AC_DEFINE(HAVE_LONG_FILE_NAMES)
  2366. fi
  2367. ])
  2368.  
  2369. AC_DEFUN(AC_SYS_RESTARTABLE_SYSCALLS,
  2370. [AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
  2371. [AC_TRY_RUN(
  2372. [/* Exit 0 (true) if wait returns something other than -1,
  2373.    i.e. the pid of the child, which means that wait was restarted
  2374.    after getting the signal.  */
  2375. #include <sys/types.h>
  2376. #include <signal.h>
  2377. ucatch (isig) { }
  2378. int main () {
  2379.   int i = fork (), status;
  2380.   if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); }
  2381.   signal (SIGINT, ucatch);
  2382.   status = wait(&i);
  2383.   if (status == -1) wait(&i);
  2384.   exit (status == -1);
  2385. }
  2386. ], ac_cv_sys_restartable_syscalls=yes, ac_cv_sys_restartable_syscalls=no)])
  2387. if test $ac_cv_sys_restartable_syscalls = yes; then
  2388.   AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS)
  2389. fi
  2390. ])
  2391.  
  2392. AC_DEFUN(AC_PATH_X,
  2393. [AC_REQUIRE_CPP()dnl Set CPP; we run AC_PATH_X_DIRECT conditionally.
  2394. # If we find X, set shell vars x_includes and x_libraries to the
  2395. # paths, otherwise set no_x=yes.
  2396. # Uses ac_ vars as temps to allow command line to override cache and checks.
  2397. # --without-x overrides everything else, but does not touch the cache.
  2398. AC_MSG_CHECKING(for X)
  2399.  
  2400. AC_ARG_WITH(x, [  --with-x                use the X Window System])
  2401. # $have_x is `yes', `no', `disabled', or empty when we do not yet know.
  2402. if test "x$with_x" = xno; then
  2403.   # The user explicitly disabled X.
  2404.   have_x=disabled
  2405. else
  2406.   if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
  2407.     # Both variables are already set.
  2408.     have_x=yes
  2409.   else
  2410. AC_CACHE_VAL(ac_cv_have_x,
  2411. [# One or both of the vars are not set, and there is no cached value.
  2412. ac_x_includes=NO ac_x_libraries=NO
  2413. AC_PATH_X_XMKMF
  2414. AC_PATH_X_DIRECT
  2415. if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
  2416.   # Didn't find X anywhere.  Cache the known absence of X.
  2417.   ac_cv_have_x="have_x=no"
  2418. else
  2419.   # Record where we found X for the cache.
  2420.   ac_cv_have_x="have_x=yes \
  2421.             ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
  2422. fi])dnl
  2423.   fi
  2424.   eval "$ac_cv_have_x"
  2425. fi # $with_x != no
  2426.  
  2427. if test "$have_x" != yes; then
  2428.   AC_MSG_RESULT($have_x)
  2429.   no_x=yes
  2430. else
  2431.   # If each of the values was on the command line, it overrides each guess.
  2432.   test "x$x_includes" = xNONE && x_includes=$ac_x_includes
  2433.   test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
  2434.   # Update the cache value to reflect the command line values.
  2435.   ac_cv_have_x="have_x=yes \
  2436.         ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
  2437.   AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
  2438. fi
  2439. ])
  2440.  
  2441. dnl Internal subroutine of AC_PATH_X.
  2442. dnl Set ac_x_includes and/or ac_x_libraries.
  2443. AC_DEFUN(AC_PATH_X_XMKMF,
  2444. [rm -fr conftestdir
  2445. if mkdir conftestdir; then
  2446.   cd conftestdir
  2447.   # Make sure to not put "make" in the Imakefile rules, since we grep it out.
  2448.   cat > Imakefile <<'EOF'
  2449. acfindx:
  2450.     @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
  2451. EOF
  2452.   if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
  2453.     # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
  2454.     eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
  2455.     # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
  2456.     for ac_extension in a so sl; do
  2457.       if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
  2458.         test -f $ac_im_libdir/libX11.$ac_extension; then
  2459.         ac_im_usrlibdir=$ac_im_libdir; break
  2460.       fi
  2461.     done
  2462.     # Screen out bogus values from the imake configuration.  They are
  2463.     # bogus both because they are the default anyway, and because
  2464.     # using them would break gcc on systems where it needs fixed includes.
  2465.     case "$ac_im_incroot" in
  2466.     /usr/include) ;;
  2467.     *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;;
  2468.     esac
  2469.     case "$ac_im_usrlibdir" in
  2470.     /usr/lib | /lib) ;;
  2471.     *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;;
  2472.     esac
  2473.   fi
  2474.   cd ..
  2475.   rm -fr conftestdir
  2476. fi
  2477. ])
  2478.  
  2479. dnl Internal subroutine of AC_PATH_X.
  2480. dnl Set ac_x_includes and/or ac_x_libraries.
  2481. AC_DEFUN(AC_PATH_X_DIRECT,
  2482. [if test "$ac_x_includes" = NO; then
  2483.   # Guess where to find include files, by looking for this one X11 .h file.
  2484.   test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
  2485.  
  2486.   # First, try using that file with no special directory specified.
  2487. AC_TRY_CPP([#include <$x_direct_test_include>],
  2488. [# We can compile using X headers with no special include directory.
  2489. ac_x_includes=],
  2490. [# Look for the header file in a standard set of common directories.
  2491. # Check X11 before X11Rn because it is often a symlink to the current release.
  2492.   for ac_dir in               \
  2493.     /usr/X11/include          \
  2494.     /usr/X11R6/include        \
  2495.     /usr/X11R5/include        \
  2496.     /usr/X11R4/include        \
  2497.                               \
  2498.     /usr/include/X11          \
  2499.     /usr/include/X11R6        \
  2500.     /usr/include/X11R5        \
  2501.     /usr/include/X11R4        \
  2502.                               \
  2503.     /usr/local/X11/include    \
  2504.     /usr/local/X11R6/include  \
  2505.     /usr/local/X11R5/include  \
  2506.     /usr/local/X11R4/include  \
  2507.                               \
  2508.     /usr/local/include/X11    \
  2509.     /usr/local/include/X11R6  \
  2510.     /usr/local/include/X11R5  \
  2511.     /usr/local/include/X11R4  \
  2512.                               \
  2513.     /usr/X386/include         \
  2514.     /usr/x386/include         \
  2515.     /usr/XFree86/include/X11  \
  2516.                               \
  2517.     /usr/include              \
  2518.     /usr/local/include        \
  2519.     /usr/unsupported/include  \
  2520.     /usr/athena/include       \
  2521.     /usr/local/x11r5/include  \
  2522.     /usr/lpp/Xamples/include  \
  2523.                               \
  2524.     /usr/openwin/include      \
  2525.     /usr/openwin/share/include \
  2526.     ; \
  2527.   do
  2528.     if test -r "$ac_dir/$x_direct_test_include"; then
  2529.       ac_x_includes=$ac_dir
  2530.       break
  2531.     fi
  2532.   done])
  2533. fi # $ac_x_includes = NO
  2534.  
  2535. if test "$ac_x_libraries" = NO; then
  2536.   # Check for the libraries.
  2537.  
  2538.   test -z "$x_direct_test_library" && x_direct_test_library=Xt
  2539.   test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
  2540.  
  2541.   # See if we find them without any special options.
  2542.   # Don't add to $LIBS permanently.
  2543.   ac_save_LIBS="$LIBS"
  2544.   LIBS="-l$x_direct_test_library $LIBS"
  2545. AC_TRY_LINK(, [${x_direct_test_function}()],
  2546. [LIBS="$ac_save_LIBS"
  2547. # We can link X programs with no special library path.
  2548. ac_x_libraries=],
  2549. [LIBS="$ac_save_LIBS"
  2550. # First see if replacing the include by lib works.
  2551. # Check X11 before X11Rn because it is often a symlink to the current release.
  2552. for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
  2553.     /usr/X11/lib          \
  2554.     /usr/X11R6/lib        \
  2555.     /usr/X11R5/lib        \
  2556.     /usr/X11R4/lib        \
  2557.                           \
  2558.     /usr/lib/X11          \
  2559.     /usr/lib/X11R6        \
  2560.     /usr/lib/X11R5        \
  2561.     /usr/lib/X11R4        \
  2562.                           \
  2563.     /usr/local/X11/lib    \
  2564.     /usr/local/X11R6/lib  \
  2565.     /usr/local/X11R5/lib  \
  2566.     /usr/local/X11R4/lib  \
  2567.                           \
  2568.     /usr/local/lib/X11    \
  2569.     /usr/local/lib/X11R6  \
  2570.     /usr/local/lib/X11R5  \
  2571.     /usr/local/lib/X11R4  \
  2572.                           \
  2573.     /usr/X386/lib         \
  2574.     /usr/x386/lib         \
  2575.     /usr/XFree86/lib/X11  \
  2576.                           \
  2577.     /usr/lib              \
  2578.     /usr/local/lib        \
  2579.     /usr/unsupported/lib  \
  2580.     /usr/athena/lib       \
  2581.     /usr/local/x11r5/lib  \
  2582.     /usr/lpp/Xamples/lib  \
  2583.     /lib/usr/lib/X11      \
  2584.                           \
  2585.     /usr/openwin/lib      \
  2586.     /usr/openwin/share/lib \
  2587.     ; \
  2588. do
  2589. dnl Don't even attempt the hair of trying to link an X program!
  2590.   for ac_extension in a so sl; do
  2591.     if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
  2592.       ac_x_libraries=$ac_dir
  2593.       break 2
  2594.     fi
  2595.   done
  2596. done])
  2597. fi # $ac_x_libraries = NO
  2598. ])
  2599.  
  2600. dnl Find additional X libraries, magic flags, etc.
  2601. AC_DEFUN(AC_PATH_XTRA,
  2602. [AC_REQUIRE([AC_PATH_X])dnl
  2603. if test "$no_x" = yes; then
  2604.   # Not all programs may use this symbol, but it does not hurt to define it.
  2605.   AC_DEFINE(X_DISPLAY_MISSING)
  2606.   X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
  2607. else
  2608.   if test -n "$x_includes"; then
  2609.     X_CFLAGS="$X_CFLAGS -I$x_includes"
  2610.   fi
  2611.  
  2612.   # It would also be nice to do this for all -L options, not just this one.
  2613.   if test -n "$x_libraries"; then
  2614.     X_LIBS="$X_LIBS -L$x_libraries"
  2615. dnl FIXME banish uname from this macro!
  2616.     # For Solaris; some versions of Sun CC require a space after -R and
  2617.     # others require no space.  Words are not sufficient . . . .
  2618.     case "`(uname -sr) 2>/dev/null`" in
  2619.     "SunOS 5"*)
  2620.       AC_MSG_CHECKING(whether -R must be followed by a space)
  2621.       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
  2622.       AC_TRY_LINK(, , ac_R_nospace=yes, ac_R_nospace=no)
  2623.       if test $ac_R_nospace = yes; then
  2624.     AC_MSG_RESULT(no)
  2625.     X_LIBS="$X_LIBS -R$x_libraries"
  2626.       else
  2627.     LIBS="$ac_xsave_LIBS -R $x_libraries"
  2628.     AC_TRY_LINK(, , ac_R_space=yes, ac_R_space=no)
  2629.     if test $ac_R_space = yes; then
  2630.       AC_MSG_RESULT(yes)
  2631.       X_LIBS="$X_LIBS -R $x_libraries"
  2632.     else
  2633.       AC_MSG_RESULT(neither works)
  2634.     fi
  2635.       fi
  2636.       LIBS="$ac_xsave_LIBS"
  2637.     esac
  2638.   fi
  2639.  
  2640.   # Check for system-dependent libraries X programs must link with.
  2641.   # Do this before checking for the system-independent R6 libraries
  2642.   # (-lICE), since we may need -lsocket or whatever for X linking.
  2643.  
  2644.   if test "$ISC" = yes; then
  2645.     X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
  2646.   else
  2647.     # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
  2648.     # libraries were built with DECnet support.  And karl@cs.umb.edu says
  2649.     # the Alpha needs dnet_stub (dnet does not exist).
  2650.     AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
  2651.     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
  2652.       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
  2653.     [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
  2654.     fi
  2655.  
  2656.     # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
  2657.     # to get the SysV transport functions.
  2658.     # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4)
  2659.     # needs -lnsl.
  2660.     # The nsl library prevents programs from opening the X display
  2661.     # on Irix 5.2, according to dickey@clark.net.
  2662.     AC_CHECK_FUNC(gethostbyname)
  2663.     if test $ac_cv_func_gethostbyname = no; then
  2664.       AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
  2665.     fi
  2666.  
  2667.     # lieder@skyler.mavd.honeywell.com says without -lsocket,
  2668.     # socket/setsockopt and other routines are undefined under SCO ODT
  2669.     # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
  2670.     # on later versions), says simon@lia.di.epfl.ch: it contains
  2671.     # gethostby* variants that don't use the nameserver (or something).
  2672.     # -lsocket must be given before -lnsl if both are needed.
  2673.     # We assume that if connect needs -lnsl, so does gethostbyname.
  2674.     AC_CHECK_FUNC(connect)
  2675.     if test $ac_cv_func_connect = no; then
  2676.       AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
  2677.     $X_EXTRA_LIBS)
  2678.     fi
  2679.  
  2680.     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
  2681.     AC_CHECK_FUNC(remove)
  2682.     if test $ac_cv_func_remove = no; then
  2683.       AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
  2684.     fi
  2685.  
  2686.     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
  2687.     AC_CHECK_FUNC(shmat)
  2688.     if test $ac_cv_func_shmat = no; then
  2689.       AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
  2690.     fi
  2691.   fi
  2692.  
  2693.   # Check for libraries that X11R6 Xt/Xaw programs need.
  2694.   ac_save_LDFLAGS="$LDFLAGS"
  2695.   test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
  2696.   # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
  2697.   # check for ICE first), but we must link in the order -lSM -lICE or
  2698.   # we get undefined symbols.  So assume we have SM if we have ICE.
  2699.   # These have to be linked with before -lX11, unlike the other
  2700.   # libraries we check for below, so use a different variable.
  2701.   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
  2702.   AC_CHECK_LIB(ICE, IceConnectionNumber,
  2703.     [X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"], , $X_EXTRA_LIBS)
  2704.   LDFLAGS="$ac_save_LDFLAGS"
  2705.  
  2706. fi
  2707. AC_SUBST(X_CFLAGS)dnl
  2708. AC_SUBST(X_PRE_LIBS)dnl
  2709. AC_SUBST(X_LIBS)dnl
  2710. AC_SUBST(X_EXTRA_LIBS)dnl
  2711. ])
  2712.  
  2713. dnl The old Cygwin32 macro is deprecated.
  2714. AC_DEFUN(AC_CYGWIN32,
  2715. [AC_OBSOLETE([$0], [; instead use AC_CYGWIN])dnl
  2716. AC_CYGWIN])
  2717.  
  2718. dnl Check for Cygwin.  This is a way to set the right value for
  2719. dnl EXEEXT.
  2720. AC_DEFUN(AC_CYGWIN,
  2721. [AC_CACHE_CHECK(for Cygwin environment, ac_cv_cygwin,
  2722. [AC_TRY_COMPILE(,[
  2723. #ifndef __CYGWIN__
  2724. #define __CYGWIN__ __CYGWIN32__
  2725. #endif
  2726. return __CYGWIN__;],
  2727. ac_cv_cygwin=yes, ac_cv_cygwin=no)
  2728. rm -f conftest*])
  2729. CYGWIN=
  2730. test "$ac_cv_cygwin" = yes && CYGWIN=yes])
  2731.  
  2732. dnl Check for mingw32.  This is another way to set the right value for
  2733. dnl EXEEXT.
  2734. AC_DEFUN(AC_MINGW32,
  2735. [AC_CACHE_CHECK(for mingw32 environment, ac_cv_mingw32,
  2736. [AC_TRY_COMPILE(,[return __MINGW32__;],
  2737. ac_cv_mingw32=yes, ac_cv_mingw32=no)
  2738. rm -f conftest*])
  2739. MINGW32=
  2740. test "$ac_cv_mingw32" = yes && MINGW32=yes])
  2741.  
  2742. dnl Check for the extension used for executables.  This knows that we
  2743. dnl add .exe for Cygwin or mingw32.  Otherwise, it compiles a test
  2744. dnl executable.  If this is called, the executable extensions will be
  2745. dnl automatically used by link commands run by the configure script.
  2746. AC_DEFUN(AC_EXEEXT,
  2747. [AC_REQUIRE([AC_CYGWIN])
  2748. AC_REQUIRE([AC_MINGW32])
  2749. AC_MSG_CHECKING([for executable suffix])
  2750. AC_CACHE_VAL(ac_cv_exeext,
  2751. [if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
  2752.   ac_cv_exeext=.exe
  2753. else
  2754.   rm -f conftest*
  2755.   echo 'int main () { return 0; }' > conftest.$ac_ext
  2756.   ac_cv_exeext=
  2757.   if AC_TRY_EVAL(ac_link); then
  2758.     for file in conftest.*; do
  2759.       case $file in
  2760.       *.c | *.o | *.obj) ;;
  2761.       *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
  2762.       esac
  2763.     done
  2764.   else
  2765.     AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.])
  2766.   fi
  2767.   rm -f conftest*
  2768.   test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
  2769. fi])
  2770. EXEEXT=""
  2771. test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
  2772. AC_MSG_RESULT(${ac_cv_exeext})
  2773. dnl Setting ac_exeext will implicitly change the ac_link command.
  2774. ac_exeext=$EXEEXT
  2775. AC_SUBST(EXEEXT)])
  2776.  
  2777.  
  2778. dnl ### Checks for UNIX variants
  2779. dnl These are kludges which should be replaced by a single POSIX check.
  2780. dnl They aren't cached, to discourage their use.
  2781.  
  2782.  
  2783. AC_DEFUN(AC_AIX,
  2784. [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
  2785. AC_BEFORE([$0], [AC_TRY_RUN])dnl
  2786. AC_MSG_CHECKING(for AIX)
  2787. AC_CACHE_VAL(ac_cv_sys_aix,[
  2788. AC_EGREP_CPP(yes,
  2789. [#ifdef _AIX
  2790.   yes
  2791. #endif
  2792. ], [ac_cv_sys_aix=yes], [ac_cv_sys_aix=no])])
  2793. AC_MSG_RESULT($ac_cv_sys_aix)
  2794. if test $ac_cv_sys_aix = yes; then
  2795.   AC_DEFINE(_ALL_SOURCE)
  2796. fi
  2797. ])
  2798.  
  2799. AC_DEFUN(AC_MINIX,
  2800. [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
  2801. AC_BEFORE([$0], [AC_TRY_RUN])dnl
  2802. AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=)
  2803. if test "$MINIX" = yes; then
  2804.   AC_DEFINE(_POSIX_SOURCE)
  2805.   AC_DEFINE(_POSIX_1_SOURCE, 2)
  2806.   AC_DEFINE(_MINIX)
  2807. fi
  2808. ])
  2809.  
  2810. AC_DEFUN(AC_ISC_POSIX,
  2811. [AC_REQUIRE([AC_PROG_CC])dnl
  2812. AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
  2813. AC_BEFORE([$0], [AC_TRY_RUN])dnl
  2814. AC_MSG_CHECKING(for POSIXized ISC)
  2815. AC_CACHE_VAL(ac_cv_sys_isc_posix,[
  2816. if test -d /etc/conf/kconfig.d &&
  2817.   grep _POSIX_VERSION [/usr/include/sys/unistd.h] >/dev/null 2>&1
  2818. then
  2819.   ac_cv_sys_isc_posix=yes
  2820. else
  2821.   ac_cv_sys_isc_posix=no
  2822. fi
  2823. ])
  2824. AC_MSG_RESULT($ac_cv_sys_isc_posix)
  2825. if test $ac_cv_sys_isc_posix = yes; then
  2826.   ISC=yes # If later tests want to check for ISC.
  2827.   AC_DEFINE(_POSIX_SOURCE)
  2828.   if test "$GCC" = yes; then
  2829.     CC="$CC -posix"
  2830.   else
  2831.     CC="$CC -Xp"
  2832.   fi
  2833. else
  2834.   ISC=
  2835. fi
  2836. ])
  2837.  
  2838. AC_DEFUN(AC_XENIX_DIR,
  2839. [AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl
  2840. AC_REQUIRE([AC_DIR_HEADER])dnl
  2841. AC_MSG_CHECKING(for Xenix)
  2842. AC_EGREP_CPP(yes,
  2843. [#if defined(M_XENIX) && !defined(M_UNIX)
  2844.   yes
  2845. #endif
  2846. ], [AC_MSG_RESULT(yes); XENIX=yes], [AC_MSG_RESULT(no); XENIX=])
  2847. if test "$XENIX" = yes; then
  2848.   # Make sure -ldir precedes -lx.
  2849.   test $ac_header_dirent = dirent.h && LIBS="-ldir $LIBS"
  2850.   LIBS="$LIBS -lx"
  2851. fi
  2852. ])
  2853.  
  2854. AC_DEFUN(AC_DYNIX_SEQ,
  2855. [AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT])dnl
  2856. AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS")
  2857. ])
  2858.  
  2859. AC_DEFUN(AC_IRIX_SUN,
  2860. [AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT or AC_CHECK_LIB(sun, getpwnam)])dnl
  2861. AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS")
  2862. ])
  2863.  
  2864. AC_DEFUN(AC_SCO_INTL,
  2865. [AC_OBSOLETE([$0], [; instead use AC_FUNC_STRFTIME])dnl
  2866. AC_CHECK_LIB(intl, strftime, LIBS="-lintl $LIBS")
  2867. ])
  2868.